Articles in this section
Category / Section

How to restrict the moving of data while OLE drag and drop instead of copying from grid to excel in WinForms GridControl?

1 min read

OLE drag and drop

By default, the GridControl supports drag and drop of the data within the Grid or other Grids by copying the data or moving the data. But when drag and drop is performed from Grid to excel, the data is moved instead of copying.

Solution

This kind of scenario can be resolved by canceling the data movement in QueryDragDropMoveClearCells event.

C#

//Triggering the QueryDragDropMoveClearCells event        
this.gridControl1.Model.QueryDragDropMoveClearCells += new CancelEventHandler(Model_QueryDragDropMoveClearCells);
//Handling the event
void Model_QueryDragDropMoveClearCells(object sender, CancelEventArgs e)
{
   e.Cancel = true;
}

 

VB

'Triggering the QueryDragDropMoveClearCells event
AddHandler Me.gridControl1.Model.QueryDragDropMoveClearCells, AddressOf Me.Model_QueryDragDropMoveClearCells
'Handling the event
Private Sub Model_QueryDragDropMoveClearCells(ByVal sender As Object, ByVal e AsCancelEventArgs)
   e.Cancel = trueEnd Sub

 

Samples: https://www.syncfusion.com/downloads/support/directtrac/general/OLE_Drag_and_Drop_From_Grid_To_Excel1946928835.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied