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
Select Row and Cell for better solution. This solution move row indicator on DataGridView.
private void _GotoNext(object sender, EventArgs e)
{
int currentRow = DataGridView1.SelectedRows[0].Index;
if (currentRow < DataGridView1.RowCount - 1)
{
DataGridView1.Rows[++currentRow].Cells[0].Selected = true;
}
}
private void _GotoPrev(object sender, EventArgs e)
{
int currentRow = DataGridView1.SelectedRows[0].Index;
if (currentRow > 0)
{
DataGridView1.Rows[--currentRow].Cells[0].Selected = true;
}
}