将DatagridView1值复制到Datagridview2并添加 [英] Copying DatagridView1 value to Datagridview2 and Add
本文介绍了将DatagridView1值复制到Datagridview2并添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI
推荐答案
您好Praveen383,
Hi Praveen383,
试试这个:
private void Form1_Load(object sender, EventArgs e)
{
dataGridView2.AllowUserToAddRows = false;
}
private void button1_Click(object sender, EventArgs e)
{
for (int col = 0; col < dataGridView1.Columns.Count; col++)
{
dataGridView2.Columns.Add((DataGridViewColumn)dataGridView1.Columns[col].Clone());
}
for (int row = 0; row < dataGridView1.Rows.Count; row++)
{
dataGridView2.Rows.Add();
for (int col = 0; col < dataGridView1.Columns.Count; col++)
{
dataGridView2.Rows[row].Cells[col].Value = dataGridView1.Rows[row].Cells[col].Value;
}
}
}
问候,
Frankie
这篇关于将DatagridView1值复制到Datagridview2并添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文