How do I jump to the next row when user presses enter on the last column of DataGridView?
This code also gives me an error which I need to resolve:
Index is out of range must be non-negative and less than the size of
collection.
private void DataGridView1_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
int iColumn = DataGridView1.CurrentCell.ColumnIndex;
int iRow = DataGridView1.CurrentCell.RowIndex;
if (iColumn >= DataGridView1.Columns.Count - 2)
DataGridView1.CurrentCell = DataGridView1[0, iRow + 1];
else
DataGridView1.CurrentCell = DataGridView1[iColumn + 1, iRow];
}
}
catch (Exception ex)
{