Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't need to load all the data into the tree. You can use the 'virtualness' of the tree. Here's how I would do it.</p> <p>Set the RootNodeCount of the tree to the number of records in CustomerObjectList:</p> <pre><code>vstree.RootNodeCount := CustomerObjectList.Count; </code></pre> <p>Then, in the OnInitChildren event, set the child count of level 0 nodes to the number of properties you want to display:</p> <pre><code>procedure TfrmMain.vstreeInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); begin if Sender.GetNodeLevel(Node) = 0 then begin Sender.ChildCount[Node] := 4; // Comment this out if you don't want the nodes to be initially expanded Sender.Expanded[Node] := TRUE; end; end; </code></pre> <p>Now, just retrieve the correct data in the OnGetText event.</p> <pre><code>procedure TfrmMain.vstreeGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string); begin if Column &lt;= 0 then begin if Sender.GetNodeLevel(Node) = 0 then CellText := CustomerObjectList[Node.Index].Name else if Sender.GetNodeLevel(Node) = 1 then begin case Node.Index of 0: CellText := CustomerObjectList[Parent.Node.Index].Sex; 1: CellText := CustomerObjectList[Parent.Node.Index].Age; 2: CellText := CustomerObjectList[Parent.Node.Index].Hair; 3: CellText := CustomerObjectList[Parent.Node.Index].City; end; // of case end; end; </code></pre> <p>You'll probably want to add in some more range checking, just in case.</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload