//定位到指定行(樣式)
dataGridView1.ClearSelection();
dataGridView1.Rows[selectIndex].Selected = true;
//讓指定行處於選中狀態(狀態)
dataGridView1.CurrentCell = dataGridView1.Rows[selectIndex].Cells[1];
dataGridView1.CurrentRow.Selected = true;
當時使用的場景:處理行數據上移下移的情況下用的。
注:這四句需要放在dataGridView1.Refresh()的后面才會起作用,前面兩句會定位到指定的行,后面兩句會使定位到的指定行處於選中狀態,若不使用后面的兩句,而使用dataGridView1.CurrentRow.Index得到的index將會一直是0(第一行)