//假设listDataGridViewGoods是一个DataGridView, 我要把第四行设置为当前行。
//index是有0开始的。
//这里只是把那行highlight。可有可没
this.listDataGridViewGoods.Rows[3].Selected = true;
//这是主要的地方。这行后,CurrentRow就是第四行了。
this.listDataGridViewGoods.CurrentCell = this.listDataGridViewGoods.Rows[3].Cells[0];
//模拟点击事件(点击选中行)
listDataGridViewGoods_CellClick(dataGridView1, new DataGridViewCellEventArgs(0, currentIndex));
//listDataGridViewGoods_CellClick(listDataGridViewGoods, new DataGridViewCellEventArgs(listDataGridViewGoods.SelectedCells[0].ColumnIndex, listDataGridViewGoods.SelectedCells[0].RowIndex));
参考:
https://blog.csdn.net/qq_36279445/article/details/79566616
https://blog.csdn.net/heping860728/article/details/7007312
https://blog.csdn.net/dogfish/article/details/7002712