Question DataGridview copy a selected row

Poxtro

New member
Joined
Jan 11, 2009
Messages
3
Programming Experience
1-3
Hi I have abit of a problem that i think you guy's will fix quite easy for me.
i'm trying(in Vb.net) to copy a selected row from a filtered DataGridview component to another without success.

i'm Gonna paste my code here and see what you have to say about it:

VB.NET:
Dim i As Integer
        If datagrid2.ColumnCount <> DataGrid1.ColumnCount Then
            For i = 0 To DataGrid1.ColumnCount Step 1
                Try
                    datagrid2.Columns.Add(DataGrid1.Columns(i).Clone)
                Catch ex As Exception

                End Try
            Next i
            'This is my problem(Dosen't work)
            datagrid2.Rows.Add()
        Else
            'This is my problem(Dosen't work)
            datagrid2.Rows.Add(DataGrid1.Rows(DataGrid1.SelectedRows.Count))
        End If

i know the code probbobly isn't well made but it's just an example that i am supposed to implement i a bigger Project later on.

Thanks in advance //Robin
 
Last edited:
Back
Top