troubleshooting Question

datagridview in visual basic 2005, no c# please

Avatar of systems_ax
systems_ax asked on
Visual Basic.NET
23 Comments1 Solution493 ViewsLast Modified:
I have this coding which looks flawless to me.  I have 2 datagridviews on 1 form and need to be able to drag from 1 dgv to another.  it shows that the drag is initiated upon dragging but nothing gets placed into the second drv.  

Private Sub DataGridViewFrom_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridViewFrom.MouseDown
        rowindexfrom = DataGridViewFrom.HitTest(e.X, e.Y).RowIndex
        If rowindexfrom <> -1 Then
            Dim dragsize As Size = SystemInformation.DragSize
            dragBoxFromMouseDown = New Rectangle(New Point(e.X - (dragsize.Width / 2), e.Y - (dragsize.Height / 2)), dragsize)
        Else
            dragBoxFromMouseDown = Rectangle.Empty
        End If
    End Sub

    Private Sub DataGridViewFrom_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridViewFrom.MouseMove
        If (e.Button And Windows.Forms.MouseButtons.Left) = Windows.Forms.MouseButtons.Left Then
            If dragBoxFromMouseDown <> Rectangle.Empty AndAlso Not dragBoxFromMouseDown.Contains(e.X, e.Y) Then
                Dim dropeffect As DragDropEffects = DataGridViewFrom.DoDragDrop(DataGridViewFrom.Rows(rowindexfrom), DragDropEffects.Copy)

            End If
        End If
    End Sub

    Private Sub DataGridViewTo_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridViewTo.DragDrop
        Dim clientpoint As Point = DataGridViewTo.PointToClient(New Point(e.X, e.Y))
        rowindexto = DataGridViewTo.HitTest(clientpoint.X, clientpoint.Y).RowIndex
        If e.Effect = DragDropEffects.Copy Then
            Dim rowtomove As DataGridViewRow = TryCast(e.Data.GetData(GetType(DataGridViewRow)), DataGridViewRow)
            DataGridViewFrom.Rows.Insert(rowindexto, rowtomove)
        End If
    End Sub

    Private Sub DataGridViewTo_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridViewTo.DragOver
        e.Effect = DragDropEffects.Copy
    End Sub
ASKER CERTIFIED SOLUTION
Sancler

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 23 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros