i am interested to move a panel control in a form by mouse dragging. how is this possible in vb.net?
this is with moving a control on a form by mouse dragging and not the contents of a control.
any help on this highly appreciated;)
Printable View
i am interested to move a panel control in a form by mouse dragging. how is this possible in vb.net?
this is with moving a control on a form by mouse dragging and not the contents of a control.
any help on this highly appreciated;)
This should work for any control, does for panel and button:
although if you are working with a container that has children controls, I don't see how (or why) you would leave the children controls behind. Contents of the control are going along for the ride unless you want to take them out of the controlscollection of the control you want to move.Code:Private Sub Panel1_MouseMove(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Panel1.MouseMove
If e.Button = MouseButtons.Left Then
sender.Top = sender.Top + e.Y
sender.Left = sender.Left + e.X
End If
End Sub
Thanks! I will try this as soon as i reach home.