)
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 drag and drop the merged Cells in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: January 3, 2016 |
Last Revised Date: December 18, 2019

Dragging and dropping for merged cells

By Default, GridControl Drag and Drop operation is done for merged cells. But merge cell cannot be moved as merged cell. For more information, please refer the below image,

Drag the merged cells in grid

 

Solution

In order to achieve drag and drop of merged cells, QueryCanOleDragRange event can be used and merged cell will be considered as individual cells by adding the drag and drop range to selection. So that merge cells also can be dragged to another place as merge cells.

 

C#

//QueryCanOleDragRange event.
void gridControl1_QueryCanOleDragRange(object sender, GridQueryCanOleDragRangeEventArgs e)
{
      if (e.Range.Left != e.Range.Right || e.Range.Top!=e.Range.Bottom)
      this.gridControl1.Selections.Add(e.Range);
}

 

VB

‘QueryCanOleDragRange event.
Private Sub gridControl1_QueryCanOleDragRange(ByVal sender As Object, ByVal e As GridQueryCanOleDragRangeEventArgs)
    If e.Range.Left <> e.Range.Right OrElse e.Range.Top<>e.Range.Bottom Then
        Me.gridControl1.Selections.Add(e.Range)
    End If
End Sub
 

 

Screenshot

 

Drag and drop the merged cells in grid

 

Samples:

C#: DragDrop_MergedCells_CS

VB: DragDrop_MergedCells-VB 

 

Reference link: https://help.syncfusion.com/windowsforms/grid-control/drag-and-drop#blocking-the-data-before-dragging

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