Just added a new column to my table/grid editor, the NxTreeColumn, but after adding a number of nodes from a VirtualStringTree, the expand button is not working. Otherwise everything is fine.
I looked at your demo4 code and could not find any setting to make this work.
Any suggestions?
Here's my routine:
//ParentNode is defined as Public var, folder node to which table is assigned
//TreeCol
procedure TfrmCVTable.MakeFirstColTree(Tree: TVirtualStringTree;
TreeCol:boolean; ParentNode :PVirtualNode);
//local procedure
//ParentIndex : row position of parent adding to
//Level: 0-n deep, 0 is the first, most left aligned level
procedure AddAllChildrenToTreeCol(Node, ParentNode : PVirtualNode;
ParentIndex, Level: integer);
var
//initialize all children of the node
Data : PNodeData;
ChildNode : PVirtualNode;
RowIndex : integer;
begin
if Node = ParentNode then
begin
Node := Node.FirstChild;
end;
while Node <> nil do
begin
Data := Tree.GetNodeData(Node);
with GridView1 do
begin
if Level = 0 then
begin
AddRow
end
else
if Level > 0 then
//parentIndex = RowIndex of the calling routine
AddChildRow(ParentIndex);
RowIndex := LastAddedRow;
Cells[1,LastAddedRow] := Data.Description;
end; //with gridview1
//check node for children and add those
Tree.ReinitChildren(node,false);
ChildNode := Node.FirstChild;
if ChildNode <> nil then
begin
AddAllChildrenToTreeCol(ChildNode, ParentNode, RowIndex,Level + 1);
end;
GridView1.Expanded[ParentIndex] := false;
Node := Node.NextSibling;
end; //while Node <> nil
end;
//end of local procedure
var
Node : PVirtualNode;
i : integer;
Data : PNodeData;
begin
if TreeCol then
begin
//start with the node to which the table is being added
Node := ParentNode;
Data := TV.CurrentCVTree.GetNodeData(Node);
GridView1.ClearRows;
NxTextColumn1.Visible := false;
GridView1.Columns.Add(TNxTreeColumn, Data.Description );
with TNxTreeColumn(GridView1.Columns[1]) do
begin
options := [coCanClick, coCanInput, coPublicUsing, coShowTextFitHint];
ShowLines := true;
//Node := Tree.FocusedNode;
//make sure the node.childcount is correct and tree nodes'data is available
Tree.ReinitChildren(node,false);
//next is recursive
//parent Index at start is 0
AddAllChildrenToTreeCol(Node, ParentNode, 0,0);
end;
end; //if TreeCol
end;