Open form at location over a TreeView

Hi

I am trying to open a windows form at a point over a TreeView
How do I do this?
I tried using the following line to load my form at the point where my mouse is but that didn't work
 Form1.Location = Me.PointToClient(System.Windows.Forms.Cursor.Position)
Form1.show
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SStoryConnect With a Mentor Commented:
    Private Sub TreeView1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseUp
        Dim f As New Form2
        f.StartPosition = FormStartPosition.Manual
        f.Location = f.PointToScreen(New Point(Me.Location.X + e.X, Me.Location.Y + e.Y))
        f.Show()

    End Sub

Open in new window


You have to be sure to set FormStartPosition to Manual. You'll also probably want to declare the second form variable at the module level, but this should do it.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.