' Copy rows from the first datagridview to the second datagridview that is data bound ' First copy the second datagridviews datasource into a new data table Dim dt As DataTable = CType(frmEncodeDatabase.EncodingDataGridView.DataSource, DataTable).Copy Dim dr As DataRow ' Loop through all rows of the first datagridview and copy them into the data table For r As Int32 = 0 To Me.DataGridViewX1.Rows.Count - 1 If Me.DataGridViewX1.Rows(r).IsNewRow = False Then ' Do not copy the new row dr = dt.NewRow ' Loop through all cells of the first datagridview and populate the data row For c As Int32 = 0 To Me.DataGridViewX1.ColumnCount - 1 dr(c) = Me.DataGridViewX1.Rows(r).Cells(c).Value Next dt.Rows.Add(dr) ' Add the data row to the data table End If Next Me.DataGridView2.DataSource = dt ' Rebind the second datagridview with the new table which has all the rows from both datagridviews frmEncodeDatabase.show()
dt As DataTable = CType(frmEncodeDatabase.EncodingDataGridView.DataSource, DataTable).Copy
frmEncodeDatabase.EncodingDataGridView.DataSource
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)