Live Chat Icon For mobile
Live Chat Icon

How can I implement OLE Drag & Drop between a DataGrid and another OLE DnD object that supports the Text format

Platform: WinForms| Category: Datagrid

The attached samples (C#, VB) 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.
  • Share with

    Share on twitter
    Share on facebook
    Share on linkedin

    Related FAQs

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.