Ok, so I’m taking my first stab at Drag-Drop functionality here. I’ve handled mouse down and called DoDragDrop from my source control.
What I’m trying to achieve is copying/ moving an account from one MDI child to another. In my context it makes no sense whatsoever to drop back onto the source control.
I’m looking at the drag enter, where you provide information regarding the current effect.
I’m wanting something that would look like the following:
If(eventData.Source != accountList)
{
eventData.Effect = DragDropEffects.Copy;
}
However, I can’t seem to find any way of determining the source control of the data. The only thing I could think of doing was having a custom class and pass that in the data with the source control embedded in that, or am I missing something obvious?
Is this in WPF? If it is, then you can make use of the
OriginalSourceproperty of the event that is passed to your methods as that should map to the source you pass when you call the DoDragDrop method.If you are using Windows Forms, you can’t pass your own source when you start the operation, so your best bet is to append the
IDataObjectyou create with custom data and determine the source based on that.Drap-drop use cases are insane in my opinion, make sure you also cover cases where a drag starts from an external application as you’ll be receiving the same DragEnter and all other methods as if you had started it in your application.