110,536
社区成员
发帖
与我相关
我的任务
分享
//First is to scroll down the DataGridView so the row is visible in the screen:
//首先滚动到相应的行使其可见
dataGridView1.FirstDisplayedScrollingRowIndex = index;
dataGridView1.Refresh();
//Then you must select the row so that binding sources update their Current item:
//然后设置相应行的第一格为当前单元格
dataGridView1.CurrentCell = dataGrid.Rows[index].Cells[0];
//Finally, you can visually select the row with C#:
//最后设置该行为选中状态
dataGridView1.Rows[index].Selected = true;
int rowIndex=3;//指定行号
this.dgvInGoodsInfo.Rows[rowIndex].Selected = true;
this.dgvInGoodsInfo.CurrentCell = this.dgvInGoodsInfo.Rows[rowIndex].Cells[0];