1
Answer

set focus to the next cell of datagridview in c#.net

chirag makwana

chirag makwana

11y
2.3k
1
I have a datagridview in windows forms, the default behavior when editing values is that after the edition of a cell, when I press enter, the selected row changes to the next cell. is it possible???
Answers (1)
0
Shweta Lodha

Shweta Lodha

NA 15.7k 878.9k 11y
Hi Chirag,
You can capture KeyDown event and select the row on pressing Enter:

void dataGridView_KeyDown(object sender, KeyEventArgs e)
{
     if (e.KeyCode == Keys.Enter)
    {
            this.dataGridView.CurrentRow.Selected = true;
            e.Handled = true;
    }
}