troubleshooting Question

DataGridRow add a row from one DataGRidView to another

Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland asked on
Visual Basic.NET
3 Comments1 Solution277 ViewsLast Modified:

I using the following code to add a row from one DataGridView to another
but am having two issues.
Firstly the event doesn't fire and secondly I get an error in the second procedure.

Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick

            Dim oIndex = e.RowIndex
            Call AddRowToDGV2(oIndex)
        Catch ex As Exception

        End Try

    End Sub
    Sub AddRowToDGV2(ByVal intRowIndex As String)
            Dim row As DataGridViewRow = Me.DataGridView1.Rows(intRowIndex)
            'This is where the row from the ist DGV is effectively copied and added to the second DGV
            If row IsNot Nothing Then

                Dim newRow As New DataGridViewRow()


                For i As Integer = 0 To row.Cells.Count - 1
                    newRow.Cells(i).Value = row.Cells(i).Value
                If Me.DataGridView1.Rows(row.Index).DefaultCellStyle.ForeColor <> Color.OrangeRed Then
                    'Don't add the row if it is already owolintshi
                End If

            End If
            '***Color line orange -on the drop
            Me.DataGridView1.Rows(row.Index).DefaultCellStyle.ForeColor = Color.OrangeRed

            MsgBox("There was a problem calling the scenario loading from a drag and drop")
        End Try
    End Sub

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 3 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 3 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