加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 08:06:54 所属栏目:百科 来源:网络整理
导读: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 D
    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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读