We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I drag labels within a Panel in .Net?

Thread ID:





510 Jul 2,2002 04:09 PM UTC Jul 3,2002 11:54 AM UTC WinForms 2
Tags: FAQ
Asked On July 2, 2002 04:09 PM UTC

Try to use the mouse to drag a label around during inside a panel. In VB6, just need to set the label DragMode to 1 and vb will take care of the X,Y position of the label. How do I do the same in .Net? Thanks a lot for your help.

Clay Burch [Syncfusion]
Replied On July 3, 2002 05:48 AM UTC

If you look at the second solution (suggested by Jacob Grass) in the FAQ referenced below, you will see how you can drag a form around by mousing down on it. This is done by handling some mouse events. In this code, if you replace the Form replace your label, you would drag the label. So, one solution would be to derive a DragLabel class, and put this code into that class. Instead handling the events at the form level, you would override the virtual OnMouseDown, OnMouseUp and OnMouseMove and place the code there. You would also want to stop the moving if the user tried to drag outside the panel (the label's Parent).Then any time you need a drag label, you would use your derived label. George Shepherd's Windows Forms FAQ contains an entry entitled: How can I drag a window if it doesn’t have a title bar or border? Check it out at: http://www.syncfusion.com/faq/winforms/search/699.asp

Replied On July 3, 2002 11:54 AM UTC

Hi Clay, Thanks for the link, just got one more question. If I need to drag an item from the list box to the panel, which event will capture the location of the drop point. I can use the panel mouse move event to capture the location inside the panel but it won't work when I try to drag an item into the panel. Any idea? Thanks.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon