[RESOLVED] To insert nodes in treeview
CIAO
First I thank the members here for helping what I needed. I can put an image in a Treeview control.
Q. How can I put nodes (add nodes) in the treeview, I know about the node click event but on runtime there is no node. How can I put nodes there so there may be nodes on runtime?
Thanks in Advance
Re: To insert nodes in treeview
You can add to the form open event
VB Code:
With TreeView
.Nodes.add , , "Node1","Node 1"
End with
HTH
Re: To insert nodes in treeview
how do you add "sub nodes"
Re: To insert nodes in treeview
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
Re: To insert nodes in treeview