[转]DataGridViewRow 添加到 dataGridView1的方法
DataGridViewRow dgvr = new DataGridViewRow();
int y= dataGridView1.Rows.Add(dgvr);
dgvr.Cells[0].Value = "1";
dgvr.Cells[1].Value = "2";
DataGridViewRow dgvr1 = new DataGridViewRow();
foreach (DataGridViewColumn c in dataGridView1.Columns)
{
dgvr1.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);//给行添加单元格
}
dgvr1.Cells[0].Value = "3";
dgvr1.Cells[1].Value = "4";
int x= dataGridView1.Rows.Add(dgvr1);