Author: Tomas Rutkauskas
I have TreeView1, Button1 and ListBox1. ListBox one has x number of items. I need
to be able to click Button1 and the items in ListBox1 are inserted as sub-items to
the selected tree-node.
Answer:
1 var2 ix: integer;
3 parentnode: TTreeNode;
4 5 TreeView.Items.BeginUpdate;
6 try7 parentnode := TreeView.FocusedNode;
8 for ix := 0 to ListBox1.Items.Count - 1 do9 begin10 if parentnode = nilthen11 Tree.Items.Add(nil, ListBox1[ix])
12 else13 Tree.Items.AddChild(parentnode, ListBox1[ix]);
14 end;
15 finally16 TreeView.Items.EndUpdate;
17 end;