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

mm马上给分!DataGridView定位到某一行!
马上给分,我在DataTable添加一新行,DataGridView如何马上定位到当前添加的新行上!

------解决方案--------------------
// 把选中的行移动到用户新增的那行(最后一笔)
DataGridView.CurrentCell = DataGridView.Rows[this.DataGridView.Rows.Count - 1].Cells[0];
------解决方案--------------------
DataGridViewCell cell = this.dataGridView1[0,1];
this.dataGridView1.CurrentCell = cell;

定位到第二行
不过要事前判断行数,不然出错
------解决方案--------------------
DataGridView.CurrentCell = DataGridView.Rows[你要的行索引].Cells[0];