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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...