Search code examples
delphivirtualtreeview

How to get a visible root node in Virtual TreeView?


I am using Virtual TreeView and I need to select the root node when I click on the button. There is a RootNode property in TBaseVirtualTree, but based on the documentation, it is not used for enumeration. Also that root node is invisible and not the actual root of the whole tree.


Solution

  • Use code like the following to select the first node. Note that there is a separate function to get the first visible node (GetFirstVisible())

    procedure TForm1.Button4Click(Sender: TObject);
    var
      node: PVirtualNode;
    begin
      node := VST.GetFirst();
      VST.Selected[node] := True;
    end;