开发windows form程序时,dataGridView不绑定数据库,我点击这个按钮几次,数据只能在最后面的那条上有,前面增加的数据自动清除掉了,如果我手动修改这些内容,则不会自动消失了,奇怪
private void button3_Click(object sender, EventArgs e)
{
this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[1].Cells[1].Value = "1111,111";
this.dataGridView1.Rows[this.dataGridView1.NewRowIndex].Cells[2].Value = "2222222222";
this.dataGridView1.Rows[this.dataGridView1.NewRowIndex].Cells[3].Value = "wwwwwwwwwww";
}
private void button3_Click(object sender, EventArgs e)
{
this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[1].Cells[1].Value = "1111,111";
this.dataGridView1.Rows[this.dataGridView1.NewRowIndex].Cells[2].Value = "2222222222";
this.dataGridView1.Rows[this.dataGridView1.NewRowIndex].Cells[3].Value = "wwwwwwwwwww";
}
int index = this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[index].Cells[0].Value = "1111,111";
this.dataGridView1.Rows[index].Cells[1].Value = "2222222222";