[RESOLVED] VS2005: How to determine which node was double-clicked
Can anyone help to determine which node was double-clicked when the doubleclick event fires for the treeview?
I am currently using an imagelist with the treeview nodes. To avoid having the selectedimage display when a node is clicked, I am cancelling the event when the BeforeSelect event fires. Therefore, the node that was just clicked is not the selected node. So I can't use the selectednode property to determine the node that was double-clicked. Any other ideas?
Re: VS2005: How to determine which node was double-clicked
The treeview control has a NodeMouseDoubleClick property that will fire when a node is double clicked
You can then determine the node by e.Node
Re: VS2005: How to determine which node was double-clicked
Here is a quick and dirty to get you started
Code:
Private Sub tvwMenu_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwMenu.AfterSelect
Select Case e.Node.Name
Case "node1"
Case "node2"
Case Else
End Select
End Sub
D
Re: VS2005: How to determine which node was double-clicked
I suppose I should have looked a bit closer. So many events compared to VB6. Thanks for the help.
Is there a better way to avoid having the image of a node change when it is selected? Seems odd that feature can't be disabled.
Re: VS2005: How to determine which node was double-clicked
Do you have a selected image? if not, then just make the selected image the same as the other image and therefore it will look the same. I haven't really played with images in treeviews so not really sure, but seems like a viable solution.
Re: VS2005: How to determine which node was double-clicked
You can/should use an image list in conjuction with your treeview. It makes it alot easier to control what images are being used when and where with it. ImageList is one of the properties on the treeview control. Under the Collection properties if you add a dummynode you will see that there are different image settings included selectedimage.
Good Luck!! :wave:
D
Re: VS2005: How to determine which node was double-clicked
Excellent. Thanks for the help.
Re: VS2005: How to determine which node was double-clicked
I just did some playing around with it and yes... you can set the selectedimage to the same thing as the item image. That way, the image does not change when you select something. I am guessing this is what you are trying to accomplish, if I am wrong please let me know.