copy Datagridview value to another datagridview
-
hi!! I have a datagridview in a form. i want to send all the data from the first datagridview to another datagridview, which is present on another form. Best Regards,
-
Which part are you have trouble with? Have you worked out how to communicate with another form yet? (e.g. call a function in another form?)
Life goes very fast. Tomorrow, today is already yesterday.
-
Well assuming you have the same columns set up in both tables then you can iterate through the Rows property and add each one. Something like...
foreach(DataGridViewRow row in dgv1.Rows)
{
dgv2.Rows.Add(row);
}You would obviously need to pass the first DGV's Rows collection to the second form to be processed
Life goes very fast. Tomorrow, today is already yesterday.
modified on Thursday, November 11, 2010 8:58 AM
-
Well assuming you have the same columns set up in both tables then you can iterate through the Rows property and add each one. Something like...
foreach(DataGridViewRow row in dgv1.Rows)
{
dgv2.Rows.Add(row);
}You would obviously need to pass the first DGV's Rows collection to the second form to be processed
Life goes very fast. Tomorrow, today is already yesterday.
modified on Thursday, November 11, 2010 8:58 AM
when i insert your code the following errors occured.
No row can be added to a DataGridView control that does not have columns. Columns must be added first
. and when i insert column by following code:
foreach (DataGridViewColumn c1 in dataGridView1.Columns)
{
DataGridViewColumn c2 = (DataGridViewColumn)c1.Clone();dataGridView2.Columns.Add(c2); }
this error occured:
Row provided already belongs to a DataGridView control.
-
when i insert your code the following errors occured.
No row can be added to a DataGridView control that does not have columns. Columns must be added first
. and when i insert column by following code:
foreach (DataGridViewColumn c1 in dataGridView1.Columns)
{
DataGridViewColumn c2 = (DataGridViewColumn)c1.Clone();dataGridView2.Columns.Add(c2); }
this error occured:
Row provided already belongs to a DataGridView control.
-
hi!! I have a datagridview in a form. i want to send all the data from the first datagridview to another datagridview, which is present on another form. Best Regards,
What is the collection that is used to populate the DGV, datatable, List<>, array[] or is the DGV manually created with no underlying collection.
Never underestimate the power of human stupidity RAH