开发者

How to enable Drag & Drop for all the children controls

My situation is as follows, I have win-forms applications with DockPanel Suite and lots of controls, which cover the entire screen,

I want to enable D&D of files from the windows explorer to the application. I know how to implement the D&D, but it seems that if i enable it for the main parent form, only the applications title-bar and task-menu icon reflect the change in the D&D.

I want the entire form to accept the files from the explorer. Do i have to enable D&D of files for each top control displaying in my application?

I am sure there is a better way to implement this, help?

Clarify

When a user drags 开发者_JAVA百科files from the windows explorer to my form, I want every place in the form to give a feedback for such an event. Much like you can drag a file from the explorer to the Visual Studio, and it doesn't matter to where you drag it, the application accepts the file.


I've not used DockPanel suite, but with Visual Studio form designer creating form drop enabled and appropriate handers on the form, almost everything I add (no properties changed) allows the form to "see" the drag/drop. Including, Panel, SplitContainer, TabControl, ListBox, Button, ListView. The only thing I tried that didn't work (and the question I had when I arrived at this page) was the RichText control, I guess that's because it allows Drag-n-Drop editing.

My guess would be this is DockPanel suite specific behaviour. I don't know anything about that, but I'd guess it has to consume drag-n-drop to implement its dock functions. Maybe there are events you can hook at the DockPanel panel level rather than the form level.


I had a similar problem using components from DevExpress, but managed to solve it by making sure all user controls had AllowDrop = false set. Basically, run a search for AllowDrop = true on the solution and make sure ONLY your main form has it set (you can remove all such lines from all affected designers since false is the default value.

This allows me to have one place that handles all drag/drop operations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜