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