1. 在行尾添加新的一行數據DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridView1); row.Cells[0].Value = 23; row.Cells[1].Value = 45; this.dataGridView1.Rows.Add(row);
2. 修改某一行的數據
int iRowIndex = n;
this.dataGridView1["Column1", iRowIndex].Value = "1";
this.dataGridView1["Column2", iRowIndex].Value = "張三";
this.dataGridView1["Column3", iRowIndex].Value = "軟件部";
3. 在行首插入一天記錄,不會覆蓋原來數據,也可在任意位置插入
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(dataGridView1);
row.Cells[0].Value = "hh";
row.Cells[1].Value = "yy";
this.dataGridView1.Rows.Insert(0, row);