This adds 1 Root node, 3 Children nodes, and 2 more Children of the 3rd child. As you can see the relations are made with the KEY parameter, that specifies who will be the father of that child.
The last parameter (the number), is the image index in the imagelist. If you dont want to add images remove that last parameter, else add an imagelist with some images (this uses 2) and go to your Treeview properties and select the Imagelist to use.
VB Code:
Private Sub Form_Load() With TreeView1 'Add the Root Node .Nodes.Add , , "Root", "Root", 1 '3 sons of Root .Nodes.Add "Root", tvwChild, "Children 1", "Children 1", 2 .Nodes.Add "Root", tvwChild, "Children 2", "Children 2", 2 .Nodes.Add "Root", tvwChild, "Children 3", "Children 3", 2 '2 sons of Children 3 .Nodes.Add "Children 3", tvwChild, "Children 4", "Children 2", 2 .Nodes.Add "Children 3", tvwChild, "Children 5", "Children 3", 2 End With End Sub




Reply With Quote