Articles in this section
Category / Section

How to drag and drop the merged Cells in WinForms GridControl?

1 min read

Dragging and dropping for merged cells


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


 

Drag the merged cells in grid

 

Solution

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

//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);
}
'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

The screenshot below displays the merged cells.

 

Drag and drop the merged cells in grid

 


Samples
:

C#: DragDrop_MergedCells_CS

VB: DragDrop_MergedCells-VB 

 

Reference Link: Drag and Drop

 

Conclusion


I hope you enjoyed learning about how to drag and drop the merged Cells in WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.


For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied