日期:2014-05-19  浏览次数:20797 次

DataGridView记录如何移动?
如何通过按钮点击使DataGridView的记录下移,上移,到记录尾,到记录首呢?

------解决方案--------------------
那你使用DataGridView.CurrentCell 属性 来设置就可以了:

比如:
this.dataGridView1.CurrentCell = this.dataGridView1[3, 10];

又如:
//向下移动一行
this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, this.dataGridView1.CurrentCell.RowIndex + 1];

//向上移动一行
this.dataGridView1.CurrentCell = this.dataGridView1[this.dataGridView1.CurrentCell.ColumnIndex, this.dataGridView1.CurrentCell.RowIndex- 1];