.NET - UserControl Drag & Drop - Child Controls

邮差的信 提交于 2019-12-10 18:14:15

问题


I have FlowLayoutPanel and UserControl's on it with drag & drop reordering. This sort of works. But the problem is that child controls prevent dragging of the actual parent UserControl.

So my question is how to enable dragging of a UserControl that contains child controls?


回答1:


If I understand you right I had the same problem as you and I solved it by propagating events of the child element to it's parent.

If you have a draggable UserControl containing a label. You have to call the events of the UserControl when the events of the label occurs. E.g. in the Label's OnMouseDown() call the UserControl's OnMouseDown() and just pass the Event-Args. I didn't find a better way than handling each event that is required for drag and drop separately.



来源:https://stackoverflow.com/questions/9773860/net-usercontrol-drag-drop-child-controls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!