How can I implement OLE Drag & Drop between a DataGrid and another OLE DnD object that supports the Text format
The attached samples (C#
) have a derived datagrid that supports OLE D&D with any OLE D&D provider that handles a Text formatted data object. The derived grid handles six events to allow it to be both a drop source and a drop target. The sample project has two datagrids where you can drag cell text back and forth. You can also open Excel, and drag text between Excel and either datagrid.
Here are the events that are handled in this sample.
MouseDown - Used to save the row and column of a mousedown, ’mousedowncell’.
MouseMove - Checks to see if you drag off the mousedowncell, and if so, starts a the DoDragDrop.
MouseUp - Used to reset the mousedowncell.
DragEnter - Checks to see if the data object has text, and if so, allows a Copy operation. (This could be changed to support Move/Copy.)
DragOver - Used to set a NoDrop cursor if you move over the mousedowncell (if mousedowncell has been set).
DragDrop - Used to drop the text into the datagrid.