Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
Assistant in the code: Move the site form (in the maintenance of and moving the place of the form) through the tool menuStrip1! In Visual Basic Net?
Posted

Use Form.Location:
http://msdn.microsoft.com/en-us/library/ms159414.aspx[^].

It's up to you what events of menu strip you need to use — you did not explain what behavior do you want. But it should not be a problem, too.

—SA
 
Share this answer
 
I think that is, what you want:

VB
' Some variables
Dim moveX, moveY As Integer
Dim newpoint As New Point

' Setting up Point 'newpoint'
Private Sub MnD() Handles MenuStrip1.MouseDown
moveX = Control.MousePosition.X - Me.Location.X
moveY = Control.MousePosition.Y - Me.Location.Y
End Sub

' Moving form through ToolStripMenu
Private Sub MnM(sender As Object, e As MouseEventArgs) Handles MenuStrip1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
newpoint = Control.MousePosition
newpoint.X -= moveX
newpoint.Y -= moveY
Me.Location = newpoint
Application.DoEvents()
End If
End Sub


~ Stefan Wittwer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900