The
MouseDown
and
MouseMove
events of a control. Here is an example (in C#) that is easy to understand and demonstrates a method:
location - Moving a control by dragging it with the mouse in C# - Stack Overflow[
^] which translates to:
Private MouseDownLocation As Point
Private Sub pictureBox1_MouseDown(sender As Object, e As MouseEventArgs)
If e.Button = System.Windows.Forms.MouseButtons.Left Then
MouseDownLocation = e.Location
End If
End Sub
Private Sub pictureBox1_MouseMove(sender As Object, e As MouseEventArgs)
If e.Button = System.Windows.Forms.MouseButtons.Left Then
pictureBox1.Left = e.X + pictureBox1.Left - MouseDownLocation.X
pictureBox1.Top = e.Y + pictureBox1.Top - MouseDownLocation.Y
End If
End Sub