Private Sub dgvOriginating_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgv1.MouseDown
Dim iSource As DataGridView = sender
iGridSourceName = iSource.Name
'Debug.WriteLine(iSource.Name)
dgv1.DoDragDrop(dgv1.SelectedRows, DragDropEffects.Copy)
End Sub
Private Sub dgvDropping_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgv1.DragEnter
Dim i As Integer
For i = 0 To e.Data.GetFormats().Length - 1
If e.Data.GetFormats()(i).Equals("System.Windows.Forms.DataGridViewSelectedRowCollection") Then
e.Effect = DragDropEffects.Copy
End If
Next
End Sub
Private Sub dgvDropping_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgv1.DragDrop
Dim iDest As DataGridView = sender
'Debug.WriteLine(iDest.Name)
If iGridSourceName = iDest.Name Then Exit Sub
Dim row, lclrow As DataGridViewRow
Dim ii As Integer
If e.Effect = DragDropEffects.Copy Then
For ii = 0 To e.Data.GetFormats().Length - 1
Console.WriteLine(e.Data.GetFormats()(ii).ToString)
Next
Dim rc As DataGridViewSelectedRowCollection = e.Data.GetData("System.Windows.Forms.DataGridViewSelectedRowCollection")
For Each row In rc
lclrow = New DataGridViewRow
lclrow.CreateCells(dgv1)
For ii = 0 To lclrow.Cells.Count - 1
lclrow.Cells(ii).Value = row.Cells(ii).Value
Next
dgv1.Rows.Add(lclrow)
Next
End If
End Sub