C# – Focus next control when pressing ‘TAB’ key

cdatagridview

I have a DataGridView where I manage manually the focused cells when navigating with Tab key. For example, when the first cell from the last row is the last cell than can be navigated in the DataGridView I want that when pressing Tab the focus to go on the next focusable control (a button).

SendKeys.Send("{TAB}") will not work – the focus will go to the second cell on the last row

Best Answer

If you set the StandardTab property to True then the behavior of the Tab key will change from moving to the next grid cell to moving to the next control on the form. This may be what you want.

If you want to control which grid cell/column/row gets focused then you can handle the ProcessDialogKey and ProcessDataGridViewKey events in your code.

Related Topic