Hello
I want to drag and drop rows between 2 datagridview binded to the same table.I want to place a row from datagridview 2 to a certain index row in the datagridview1 because I need the order of the row in the datagridview1.

For example I want to change the position of the row of CMD2 to the first row in datagridview1
Here's my code:
Private Sub DataGridView1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
Dim clientPoint As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))
Dim hit As DataGridView.HitTestInfo = DataGridView1.HitTest(clientPoint.X, clientPoint.Y)
Dim dgvr As DataGridViewRow = DirectCast(e.Data.GetData(GetType(DataGridViewRow)), DataGridViewRow)
Dim celldata As Object() = New Object(dgvr.Cells.Count - 1) {}
For col As Integer = 0 To dgvr.Cells.Count - 1
celldata(col) = dgvr.Cells(col).Value
Next
Dim row As DataRow = ds_data.Tables(0).NewRow()
row.ItemArray = celldata
ds_data.Tables(0).Rows.InsertAt(row, DataGridView1.NewRowIndex)
dgvr.DataGridView.Rows.Remove(dgvr)
End Sub
Private Sub DataGridView1_DragEnter(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter
If e.Data.GetDataPresent(GetType(DataGridViewRow)) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub DataGridView2_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView2.MouseMove
If e.Button = MouseButtons.Left Then
Me.DataGridView1.DoDragDrop(Me.DataGridView1.CurrentRow, DragDropEffects.All)
End If
End SubHope I'm clear
Thanks in advance
Best Regards...Please mark as answer if my post is helpful http://yosr-jemili.blogspot.com