views:

71

answers:

1

Hello,

I know how to do drag and drop in C# when it comes to files.

I can take a file off my desktop and drop it on my C# app (onto a button) and that works fine. However, if I have Firefox loaded, and I try to drag the web page link I am viewing and drop it onto my C# app, I am unable to do it (I get a circle with a slash through it).

I can drag the link to my desktop first, drop it, then drag it to my app and that works fine.

But I want to be able to drag it directly to my C# app button from the browser window.

Anyone know how I can implement this?

Thanks.

+1  A: 

Handle the DragDrop event for the button, look at the available formats, and set the allowed effects appropiately.

SLaks
I don't know how to implement what you are saying. Can you please show me some code to do that?
fraXis
@fraXis: Handle the `DragOver` event, set a breakpoint in the handler, drag something onto the button, and look at `e.Data.GetFormats()` in the debugger. Figure out which format you need, then change your code to check `e.Data.GetDataPresent` and set `e.Effect` to `Copy` (or something else) if the format you want is present.
SLaks
Then, handle the `DragDrop` event, call `e.Data.GetData(format)`, and do something with it.
SLaks
Awesome. Thanks.
fraXis