Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

DataGridRow add a row from one DataGRidView to another

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

Visual Basic.NET

Avatar of undefined
Last Comment
Murray Brown
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Murray Brown
Murray Brown
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

thanks. Sorry about late reply
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo