I want to copy selected row in gridView1/gridControl1 to gridView2/gridControl2, gridView1 with DataSource and DataTable:
private void chon2_Click(object sender, EventArgs e)
{
for (int i = 0; i < gridView1.GetSelectedRows().Length; i++)
{
gridView2.AddNewRow();
gridView2.SetRowCellValue(i, "column2",gridView1.GetRowCellValue(i, "colum1").ToString());
}
}
But it does not work
I can see that you are trying to set the row cell value within the
_Clickevent. This won't work. You need to set the row cell value(s) behind the_InitNewRowevent.Try the following:
Behind the
_Clickevent, add the following line:Create a
_InitNewRowevent via GridView > Events and you should have something that looks like this:To set the value(s), add the following: