treenode location

I want to show a form of border style none, under a treenode. I can not place it properly. If I collect e.Location the form is opening at wrong place if i drag the mouse just before the form show event. any suggestion?
Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
How about something like this?
Public Class Form1
    Private Sub TreeView1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            Dim tn As TreeNode = TreeView1.GetNodeAt(e.X, e.Y)
            If Not IsNothing(tn) Then
                Dim rc As Rectangle = TreeView1.RectangleToScreen(tn.Bounds)
                Dim f2 As New Form2
                f2.StartPosition = FormStartPosition.Manual
                f2.Location = New Point(rc.X, rc.Bottom)
            End If
        End If
    End Sub
End Class

Open in new window

Amitava_MukherjeeAuthor Commented:
Perfect Solution, Thanx
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.