Articles in this section
Category / Section

How to drag and drop records from one grid to another in a single click?

2 mins read

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 reported query can be achieved only by doing customization in grid level.

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();
        DoDragDrop(str, DragDropEffects.Move);  //Selected ranges are copied, press left && right click to paste in gridcontrol.              
    }
}

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 Sub

Samples:

C#: Draganddrop_CS

VB: Draganddrop_VB 

Conclusion

I hope you enjoyed learning about how to enable the button click only on current cell in edit mode in WinForms GridDataBoundGrid. You can refer to our WinForms GridDataBoundGrid feature tour page to know about its other groundbreaking feature representations documentation
and how to quickly get started for configuration specifications.  You can also explore our WinForms GridDataBoundGrid example
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 forumsDirect-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 sign in to leave a comment
Access denied
Access denied