The code works only when i'm adding a value at first time. The problem is that when i'm going back in a previous value which i added and i'm hitting enter it selects next cell from next row, not the next right cell.
Here is my code:
private void dataGridView1_CellEndEdit(object sender, KeyEventArgs e)
{
int col = dataGridView1.CurrentCell.ColumnIndex;
int row = dataGridView1.CurrentCell.RowIndex;
if (col < dataGridView1.ColumnCount - 1)
{
col++;
}
else
{
col = 0;
row++;
}
if (row == dataGridView1.RowCount)
dataGridView1.Rows.Add();
dataGridView1.CurrentCell = dataGridView1[col, row];
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.AllowUserToAddRows = false;
dataGridView1.Rows.Add();
}