.NET Framework - Copy from datagridview and paste to second datagridview

Asked By ing.Zeco on 28-Oct-07 08:17 PM
I need usage possibility when I double click on any row in datagridview,
that row must be copied in second datagridview.
Any good link about that?!




SomNathShukl replied on 29-Oct-07 01:43 AM
private void dataGridView1_CellClick(object sender,
DataGridViewCellEventArgs e)
{

}

in cellclick event of firdt datagrid u need to right code to add add the
selected rows to secod datagridview.
SomNathShukl replied on 29-Oct-07 02:41 AM
private void Form1_Load(object sender, EventArgs e)
{


foreach(DataGridViewColumn c1 in dataGridView1.Columns)
{
DataGridViewColumn c2 = (DataGridViewColumn)c1.Clone();

dataGridView2.Columns.Add(c2);
}
}


private void dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
DataGridViewRow r2 =
(DataGridViewRow)dataGridView2.Rows[0].Clone();
int i=0;
foreach( DataGridViewCell cell  in
dataGridView1.Rows[e.RowIndex].Cells)
{
r2.Cells[i].Value = cell.Value;
i++;
}
dataGridView2.Rows.Add(r2);
dataGridView2.Refresh();
}



try thsi one first oin pageload  add columns from first too secord datagrid
and then

in  CellContentClick event add row from first to secord datagridview.