Good day..

Can everyone help me pls..
i have created a code to create nodes in treeview and i am done with this. my problem is how can i view children's text on the treeview as well as the image when i click the parent?
here is my code.

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
For i = 1 To Node.Children
' in this area i want to view child's text using msgbox as well
'as the image
MsgBox (Node.child.text) '
Next i
End Sub

Private Sub Form_Load()
create_node
end sub

sub create_node()
Set TreeView1.ImageList = ImageList1 'cl & op images inserted in imagelist
Dim nodx As Node

Set nodx = TreeView1.Nodes.Add(, , "root", "Root", "rt")
nodx.Expanded = True

Set nodx = TreeView1.Nodes.Add("root", tvwChild, "1st","first", "cl")
nodx.ExpandedImage = "op"
Set nodx = TreeView1.Nodes.Add("1st", tvwChild, , "node1", "cl")
nodx.SelectedImage = "op"
Set nodx = TreeView1.Nodes.Add("1st", tvwChild, , "node2", "cl")
nodx.SelectedImage = "op"
Set nodx = TreeView1.Nodes.Add("1st", tvwChild, , "node3", "cl")
nodx.SelectedImage = "op"

Set nodx = TreeView1.Nodes.Add("root", tvwChild, "2nd", "Second", "cl")
nodx.ExpandedImage = "op"
Set nodx = TreeView1.Nodes.Add("2nd", tvwChild, , "node1", "cl")
nodx.SelectedImage = "op"
Set nodx = TreeView1.Nodes.Add("2nd", tvwChild, , "node2", "cl")
nodx.SelectedImage = "op"
Set nodx = TreeView1.Nodes.Add("2nd", tvwChild, , "node3", "cl")
nodx.SelectedImage = "op"

end sub

Recommended Answers

All 3 Replies

What happens when you click on the parent node . Does it not open the child nodes with its icon ?

yes it do not show the icon.. but i got the right answer to my own question. THANKS A LOT FOR THE REPLY...

dim x as node
if node.childern>0 then
   set x=node.child.firstsibiling
   do while not x is nothing
      ' do it every thing with x.
      set x=x.next
   loop
end if
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.