im trying to go next cell in datagridview after typing in the cell but it go to next row in same Column ** if not typing any thing in cell it working fine how can solve that
private void dgvacc_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int row = dgvacc.CurrentCell.RowIndex;
int col = dgvacc.CurrentCell.ColumnIndex;
try
{
if (col < dgvacc.Columns.Count - 1)
{
dgvacc.CurrentCell = dgvacc.Rows[row -1].Cells[col + 1];
dgvacc.Focus();
}
else if (col == dgvacc.Columns.Count - 1)
{
dgvacc.CurrentCell = dgvacc.Rows[row].Cells[0];
dgvacc.Focus();
}
}
catch (Exception)
{
}
}
}