Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- MasterNode: PVirtualNode;
- DetailNode: PVirtualNode;
- begin
- // move both table cursors to the beginning
- MasterTable.First;
- DetailTable.First;
- // clear and lock the virtual tree
- VirtualTree.Clear;
- VirtualTree.BeginUpdate;
- try
- // iterate the master table in the outer loop
- while not MasterTable.Eof do
- begin
- // add the master table row as the root node
- MasterNode := VirtualTree.AddChild(nil);
- // <- fill in the data for the MasterNode here
- // while we are not at the end of the detail table and the detail row is of the same ID as the master,
- // add child nodes
- while not DetailTable.Eof and (DetailTable.FieldByName('MasterID') = MasterTable.FieldByName('ID')) do
- begin
- // add a detail node as a child of the parent node added for the master table
- DetailNode := VirtualTree.AddChild(MasterNode);
- // <- fill in the data for the DetailNode here
- // move to the next detail row
- DetailTable.Next;
- end;
- // move to the next master row
- MasterTable.Next;
- end;
- finally
- VirtualTree.EndUpdate;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement