首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DataGridView记录怎么移动

2011-12-13 
DataGridView记录如何移动?如何通过按钮点击使DataGridView的记录下移,上移,到记录尾,到记录首呢?[解决办

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];

热点排行