VB.Net程序设计:拖放Datagridview到另外一个Datagridview基本操作

前端之家收集整理的这篇文章主要介绍了VB.Net程序设计:拖放Datagridview到另外一个Datagridview基本操作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
    Private Sub DvQurey_MouseMove(ByVal sender As System.Object,ByVal e As System.Windows.Forms.MouseEventArgs) Handles DvQurey.MouseMove
        If (e.Button And Windows.Forms.MouseButtons.Left) = Windows.Forms.MouseButtons.Left Then
            Dim hitTest As DataGridView.HitTestInfo = Me.DvQurey.HitTest(e.X,e.Y)
            If hitTest.Type = DataGridViewHitTestType.Cell Then
                If Me.DvQurey.SelectedRows.Count > 0 Then
                    dragData = New DragDataObject(eDragType.MoveLotSelected,Me.DvQurey.SelectedRows)
                    Me.DvQurey.DoDragDrop(dragData,DragDropEffects.Copy)
                End If
            End If
        End If
    End Sub

    Private Sub DvSelected_DragEnter(ByVal sender As Object,ByVal e As System.Windows.Forms.DragEventArgs) Handles DvSelected.DragEnter
        If e.Data.GetDataPresent(GetType(DragDataObject)) Then
            Dim drg As DragDataObject = e.Data.GetData(GetType(DragDataObject))
            If drg.DragType = eDragType.MoveLotSelected Then
                e.Effect = DragDropEffects.Copy
            End If
        End If
    End Sub

    Private Sub DvSelected_DragDrop(ByVal sender As Object,ByVal e As System.Windows.Forms.DragEventArgs) Handles DvSelected.DragDrop
        If e.Data.GetDataPresent(GetType(DragDataObject)) Then
            Dim drg As DragDataObject = e.Data.GetData(GetType(DragDataObject))
            Dim nRow As DataGridViewRow
            Dim dRow As DataGridViewSelectedRowCollection
            If drg.DragType = eDragType.MoveLotSelected Then
                If tblShow.Rows.Count > 0 Then
                    dRow = CType(drg.Data,DataGridViewSelectedRowCollection)
                    For Each nRow In dRow
                        Me.tblSelected.ImportRow(tblShow.Rows(nRow.Index))
                    Next
                    Me.tblSelected.AcceptChanges()
                    Me.DvSelected.AutoResizeColumns()
                End If

            End If
        End If
    End Sub
原文链接:https://www.f2er.com/vb/258484.html

猜你在找的VB相关文章