I want to return a treeview node level with a single mouse click (1, 2 or 3). I'm loading a treeview from a database (which works just peachy) and need to know what level I've clicked. There are up to three levels: parent, child, grandchild. What I want to do is right click on a node to get a specific context menu to deal with that node at that level. Each level will have it's own context menu.
This works to a point. But I get the level down one from the node I click. In orther words, if I click the parent node, I get the child node text.
Private Sub TreeView1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
If e.Button = MouseButtons.Right Then
Dim n As TreeNode = TreeView1.GetNodeAt(e.X, e.Y)
mnuContextLevel1.Show(TreeView1, New Point(e.X, e.Y))
I'm kinda hoping it's a simple solution since I'm running out of points. If I'm not clear enough, please let me know.