Hello Kim,
This will move a label inside the panel container. It does not check or limit the travel but you should be able to figure that out. The key to the coordinate is using the Control.PointToClient method.
Public Sub New()
InitializeComponent()
End Sub
Dim _isMoving As Boolean
Dim _pt As Point
Private Sub Label1_MouseDown(sender As Object, e As MouseEventArgs) Handles Label1.MouseDown
_isMoving = True
_pt = New Point(e.X, e.Y)
End Sub
Private Sub Label1_MouseUp(sender As Object, e As MouseEventArgs) Handles Label1.MouseUp
_isMoving = False
End Sub
Private Sub Label1_MouseMove(sender As Object, e As MouseEventArgs) Handles Label1.MouseMove
Dim pos As Point = Panel1.PointToClient(Cursor.Position)
pos.X = pos.X - _pt.X
pos.Y = pos.Y - _pt.Y
If _isMoving Then
Label1.Location = pos
End If
End Sub
Hope that helps,
regs
ron O.