Articles in this section
Category / Section

How to determine the OLE drag and drop of the WinForms GridControl?

1 min read

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,

Drag and drop data from one grid to another

Figure: Controlling the drag and drop in a GridControl

Note:

Drag and drop the items from the first grid to the second grid.

 

Samples:

C#: OLE_drag and drop

VB: OLE_drag and drop

Reference link: https://help.syncfusion.com/windowsforms/grid-control/drag-and-drop

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