What is the sequence of events in a drag/drop operation, and how should I handle them?

I am trying to drag an object from one DataGridView to another in a WinForms application being developed in MS Visual Studio 2012. The events I’m seeing do not match examples I’ve found. Most examples I’ve seen create a move reference rectangle in the control’s MouseDown event handler, and then test to see if the mouse has moved outside of that rectangle (and therefore something is being dragged) in the MouseMove event handler. But I’m not seeing the MouseMove event fire. Instead, the DragOver event is being fired.

Could someone point me to a good, comprehensive list of events that get fired during a drag and drop operation, the conditions that must be true for the event to be fired, and the actions that my code is expected to take in each event’s handler?

And in particular, I am getting the impression that it’s critical to call DoDragDrop() at the correct time or in response to the correct event, but I’m not sure what that correct time is. When should it be called?

Thanks very much.

submitted by /u/CedricCicada
[link] [comments]

Leave a Reply