Display form at cursor position
I am trying to use a windows form as a custom contextmenu which is fine as I have done a form with translucent background colour. However the problem is that I am having problems displaying the form at my cursor position. I have a mdi chaild form in my app and when I right click I want to display my custom contextmenu form at the point where I right click in the mdichild form. The only other thing is that I want the middle of the form to be displayed at the cursor point.
Thanks
Simon
Re: Display form at cursor position
try this:
vb Code:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
Dim p As Point = Cursor.Position
p.Offset(-Form2.Width \ 2, -Form2.Height \ 2)
Form2.Location = p
Form2.Show()
End Sub
Re: Display form at cursor position
Paul,
Thanks for you help, worked perfectly