Move controls when Drag and drop on panel in C#

后端 未结 2 1255
被撕碎了的回忆
被撕碎了的回忆 2020-12-10 13:37

I want to drag controls on panel and when dragging I want to move the control and get its location to drop on to panel. I have tried out mouseUp, mouseDown, MouseMove events

2条回答
  •  再見小時候
    2020-12-10 14:32

    You will need to use the mouse up and mouse down events to toggle your drag state. When you go mouse down, you start dragging. You record the relative position of the mouse within your control and the relative position of your control within the panel. You then follow the mouse as it moves and repositioning the control's top and left relative to the original location of the mouse within your control.

提交回复
热议问题