DataGridView and NextControl
-
Good Morning, i have a problem! i have a form with a DataGrid. the form have a KeyPreview properties and i placed it to true. the form events "KeyPress" i placed the following code: if (e.KeyChar == (char)13) SendKeys.Send("{TAB}") so when i click on enter and the focus is on datagrid on the first row, so the focus goes to third row and not on second. what's the problem?? Thanks a lot!
-
Good Morning, i have a problem! i have a form with a DataGrid. the form have a KeyPreview properties and i placed it to true. the form events "KeyPress" i placed the following code: if (e.KeyChar == (char)13) SendKeys.Send("{TAB}") so when i click on enter and the focus is on datagrid on the first row, so the focus goes to third row and not on second. what's the problem?? Thanks a lot!
I think you don't need to capture Enter key in DataGridView. Because normally pressing Enter causes to focus goes to next line. For activating movement by "Enter" instead of "Tab" use below code :
Form_KeyDown() { this.SelectNextControl(); }
Don't forget to set all controls TabIndex property. -
I think you don't need to capture Enter key in DataGridView. Because normally pressing Enter causes to focus goes to next line. For activating movement by "Enter" instead of "Tab" use below code :
Form_KeyDown() { this.SelectNextControl(); }
Don't forget to set all controls TabIndex property.Thanks dude! i didn't know that DataGridView has this movement by "Enter" instead of "Tab", without need to use code. it was a good tip. Thank you a lot.