DataGridRow add a row from one DataGRidView to another

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

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.
Thanks


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

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

        End Try

    End Sub
    Sub AddRowToDGV2(ByVal intRowIndex As String)
        Try
            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()

                newRow.CreateCells(Me.DataGridView1)

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

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

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

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
Most Valuable Expert 2012
Top Expert 2014
Commented:
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
thanks. Sorry about late reply

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial