DataGridView navigating to next row

前端 未结 7 863
野的像风
野的像风 2021-01-19 10:42

I have a C# winforms application and I am trying to get a button working that will select the next row in a datagridview after the one curently selected.

The code I

7条回答
  •  深忆病人
    2021-01-19 11:00

    First, set "Multiselect" property of datagridview to false.

    int currentRow = dataGridView1.SelectedRows[0].Index;
    if (currentRow < dataGridView1.RowCount)
    {
        dataGridView1.Rows[++currentRow].Selected = true;
    }
    

    It will select the next row in the datagridview.

提交回复
热议问题