find the treeview node level with a click on the node in vb. net

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) _
                    Handles TreeView1.MouseDown
        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))
            MsgBox(TreeView1.SelectedNode.Nodes(TreeView1.SelectedNode.Level).ToString)
        End If
    End Sub

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.

Randy
StateGuyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Malik1947Commented:
Why not simply use the level?





MsgBox(TreeView1.SelectedNode.Level).ToString)

Open in new window

0
StateGuyAuthor Commented:
I got an error message:
"Overload resolution failed because no accessible 'ToString' can be called with these arguments."

0
Malik1947Commented:
My bad.


  	
 
MsgBox(TreeView1.SelectedNode.Level.ToString)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StateGuyAuthor Commented:
OO-RAH!  And don't worry about the misplaced paren.  I made a mistake once myself...
<humor inetnded>
Thanks again.

Randy
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.