How to determine the OLE drag and drop of the WinForms GridControl?
OLE drag and drop
An OLE drop target of the Grid is determined by the DragDropTargetFlags in the Grid’s Model.Options class. These flags control the clipboard format type of the data, whether the columns or rows can be appended to accommodate the dropped data or not, and whether auto scrolling is supported or not. Check the enumeration for GridDragDropFlags to see the full set of options.
C#
//trigger the dragover event this.gridControl1.DragOver += gridControl1_DragOver; this.gridControl2.DragOver += gridControl2_DragOver; //turn off being a drop target gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Disabled; // turn on accepting text gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text; //accept both text and styles gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text | GridDragDropFlags.Text; void gridControl2_DragOver(object sender, DragEventArgs e) { //Forces copy of the dragged items e.Effect = DragDropEffects.Copy; } void gridControl1_DragOver(object sender, DragEventArgs e) { //Forces copy of the dragged items e.Effect = DragDropEffects.Copy; }
VB
'trigger the dragover event Private Me.gridControl1.DragOver += AddressOf gridControl1_DragOver Private Me.gridControl2.DragOver += AddressOf gridControl2_DragOver 'turn off being a drop target gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Disabled 'turn on accepting text gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text 'accept both text and styles gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text Or GridDragDropFlags.Text void gridControl2_DragOver(Object sender, DragEventArgs e) 'Forces copy of the dragged items e.Effect = DragDropEffects.Copy void gridControl1_DragOver(Object sender, DragEventArgs e) 'Forces copy of the dragged items e.Effect = DragDropEffects.Copy
After applying the properties, the grid is shown below,
Figure: Controlling the drag and drop in a GridControl
Drag and drop the items from the first grid to the second grid.
Samples:
Reference link: https://help.syncfusion.com/windowsforms/grid-control/drag-and-drop