(RAD Studio) Virtual TreeView: how to initialize all nodes at the same time?

I just opened this component and started working with it.

I understand that his whole concept is to initialize the nodes on the fly as needed, but I need them all to be initialized instantly.

What's the smart way to do this?

The only one I came up with was to use GetLast () after adding nodes.
I believe there is a better way or not?

+2


source to share


3 answers


treeview.FullExpand;



+3


source


A more correct way to initialize one node instantly is to use the ValidateNode method rather than the already suggested FullExpand. According to the VT document flow:

procedure ValidateNode(Node: PVirtualNode; Recursive: Boolean);

      



TBaseVirtualTree.ValidateNode

ValidateNode ensures that the given node (and all of its children, if Recursive is true) are initialized. If node is zero, then the hidden root is node (which only makes sense if Recursive is true, in which case the whole tree is checked).

+5


source


You can write your own procedure to create the tree manually.

Example:

procedure TForm1.BuildTree;
var
  i: integer;
  Data: ^TYourRecord;
  pNode, cNode: PVirtualNode;
begin
  for i:=0 to 1000 - 1 do
  begin
    //build parent node
    pNode := VT.AddChild(nil);
    Data := VT.GetNodeData(pNode);
    //fill record values
    Data.SomeVar := 'Parent Node';
    //build child node
    cNode := VT.AddChild(pNode);
    Data := VT.GetNodeData(cNode);
    Data.SomeVar := 'Child Node';
  end;
end;

      

+3


source







All Articles