How to set focus on a particular row in a datagrid/gridview?

前端 未结 6 1558
清酒与你
清酒与你 2021-01-04 18:07

I have a datagrid/gridview. I\'m populating the grid with 10 rows initially. On a button click every time,I\'m keeping on adding 10 rows to the datagrid/gridview. Now I want

6条回答
  •  半阙折子戏
    2021-01-04 18:53

    Try this

    dataGridView1.ClearSelection();
    int nRowIndex = dataGridView1.Rows.Count - 1;
    
    dataGridView1.Rows[nRowIndex].Selected = true;
    dataGridView1.Rows[nRowIndex].Cells[0].Selected = true;
    

提交回复
热议问题