How to drag and drop records from one grid to another in a single click?
Drag and drop by clicking the mouse button in any part of the row can be achieved by using the MouseDown event. You can use the DoDragDrop method to assign the copied range of records and apply the DragDropEffects as Move.
The following code example is for MouseDown event.
C#
//Hooking GridDataBoundGrid mouse down event.
this.gridDataBoundGrid1.MouseDown += gridDataBoundGrid1_MouseDown;
void gridDataBoundGrid1_MouseDown(object sender, MouseEventArgs e)
{
if (this.gridDataBoundGrid1.Model.Selections.Count > 0)
{
this.gridDataBoundGrid1.Model.CutPaste.Copy();
str = Clipboard.GetText();
//Selected ranges are copied, press left && right click to paste in gridcontrol.
DoDragDrop(str, DragDropEffects.Move);
}
}VB
'Hooking GridDataBoundGrid mouse down event.
Private Me.gridDataBoundGrid1.MouseDown += AddressOf gridDataBoundGrid1_MouseDown
Private Sub gridDataBoundGrid1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
If Me.gridDataBoundGrid1.Model.Selections.Count > 0 Then
Me.gridDataBoundGrid1.Model.CutPaste.Copy()
Str = Clipboard.GetText()
'Selected range are copied, press left && right click to paste in grid control.
DoDragDrop(Str, DragDropEffects.Move)
End If
End SubConclusion
I hope you
enjoyed learning about How to drag and drop records from one grid to
another in a single click.
You can refer
to our WinForms GridDataBoundGrid feature
tour page to know about its other groundbreaking feature
representations. You can also explore our WinForms GridDataBoundGrid documentation to
understand how to create and manipulate data.
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!