)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 17, 2019
Tags: dragging

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon