I've got a WinForm where the user has the ability to drag an item from it to a different application. In my case the second application is SolidWorks. I have no problem getting the drag part working. The user is able to drag the part from my application to the SolidWorks drawing, but I want to close my WinForm when the user has dropped the item in the drawing.
Is there an event I'm missing somewhere? QueryContinueDrag doesn't seem to be it. I can drop the part all day long, but QueryContinueDrag doesn't fire on the drop.
EDIT: Here's a sample of the code I use to start the drag operation. I just don't know when the drop occurs in the other app.
string[] fList = new string[1];
fList[0] = @"C:\block.sldblk";
DataObject dataObj = new DataObject(DataFormats.FileDrop, fList);
DragDropEffects eff = DoDragDrop(dataObj, DragDropEffects.Link | DragDropEffects.Copy);
Your best bet is probably to use an IDataObject as your data in the call to DoDragDrop().
Instead of putting the data you want in there directly, create a class that inherits from IDataObject to hold your data. When the user "drops" the part, then the IDataObject's "GetData" method will be called. You can use this to set a flag to close your form or give user feedback that the drop occurred.
Note that there is an implementation of IDataObject already provided - DataObject. It's normally much easier to extend or use that than try to create your own.
EDIT: I see you're using DataObject already - rather than use it, use a derived class and override GetData, this will be called when the drop occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With