Copy from datagridview and paste to second datagridview

I

ing.Zeco

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?!
 
G

Guest

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.
 
G

Guest

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.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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top