Images on Childnodes - Treeview

TryToLearnVB

New member
Joined
Dec 21, 2011
Messages
4
Programming Experience
Beginner
I am trying to figure out how to display different image on childnodes. I've used .Imagekey (after adding images to an ImageList), but it display the images on all the nodes including childnodes and their sub nodes as well. I would like know if there is an way actually to display different images on Parent Nodes, ChildNodes and their sub Nodes.

Thanks,
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
You have to set index or key for each TreeNode, default is index 0 which is first image.
Notice there are two index/key properties for each selected state.
 

TryToLearnVB

New member
Joined
Dec 21, 2011
Messages
4
Programming Experience
Beginner
Thanks JohnH for reply back. But I am still confused. This how I have coded now!

With

.Nodes.Add("Nodes")
.ImageKey = 0 'set an image to index 0

.Nodes(0).Nodes.Add("ChildNode")
.ImageKey = 1 '?

End With
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,604
Location
Norway
Programming Experience
10+
With what? TreeView? That is just setting default index/key for all nodes. Have a look at documentation for TreeNode class.
 

TryToLearnVB

New member
Joined
Dec 21, 2011
Messages
4
Programming Experience
Beginner
JonhH,

Yes, this is with TreeView. I actually want to use a default image key/index for parent node and different image key/index for childnodes.
 
Top Bottom