Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview selected node imagekey

Status
Not open for further replies.

sillysod

Technical User
Jan 6, 2004
300
GB
This is driving me crazy, i am using a treeview for the navigation tree in my app.

I have populated the tree, everything looks smashing.

Then when i select a node the image changes to the one specified in the SelectedNodeImageKey property, and this is a mandatory option. So i have to put something in there ?

How do i stop the image changing when i select a node?

I have tried using the afterselect event to immediately change the image back to the correct image, however this refreshes the treeview so collapses all at the same time.
 
In VS 2003, I just set the SelectedNodeImageKey value with the same value as the ImageIndex property value.
 
The selectednodeimageindex is a property of the treeview, so its the same no matter what node i select

however every node in my treeview has a different image....
 
It does matter.
Try this:
Code:
Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
   e.Node.SelectedImageIndex = e.Node.ImageIndex
End Sub

Good luck.
 
Even better: when you set the nodes image index you also set its selected imageindex.

theTreeNode.ImageIndex = someIndex;
theTreeNode.SelectedImageIndex = someIndex;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top