2

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 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.

Jakob Möllås
  • 4,239
  • 3
  • 33
  • 61
Amirshk
  • 8,170
  • 2
  • 35
  • 64
  • I deleted my answer/comments, feeling I should have made comments only. In VS 2010 beta 2 : dragging a .cs file from "outside" : you can drop only on VS Solution Explorer or on VS window itself. Anywhere else you drag : you just get a "can't drop here" cursor. To make every control on your app give some dragover feedback is, I think, going to require either elaborate setting of event handlers recursively for every control on your form, or some incredible hack like a transparent window over the form when the form gets a drag-enter (and I'm not sure that would work , either). best, – BillW Nov 08 '09 at 12:57
  • i think your response is a good answer, i recommend you undelete it – Amirshk Nov 12 '09 at 05:51

2 Answers2

0

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.

Jakob Möllås
  • 4,239
  • 3
  • 33
  • 61
0

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.