Home > Net >  How to make Datagridview gains focus is not automatically selected when the first line
How to make Datagridview gains focus is not automatically selected when the first line

Time:10-01

I want to encapsulate a control inheriting datagridview, but datagridview when the TAB key to get focus will automatically set the focus to the first row of data, I want to block the action, the TAB key to enter the custom controls later not set the focus to the first line, should how to do? thank you

CodePudding user response:

GotFocus event set in the first line of the Selected to false,

CodePudding user response:

reference 1st floor exception92 response:
GotFocus event set in the first line of the Selected to false,

Reply thank moderator, GotFocus Settings, if form the current focus in DataGridView, user Alt + TAB to switch to other program, switch will trigger GotFocus incident when I come back again, this will get rid of the user selected before line,
GotFocus other events can trigger in the user clicks the Datagridview

CodePudding user response:

Record before the user choose the index of the line, again enters gotfocus judge whether the index is equal to zero, not equal to zero for selected=false Settings,
Or consider the tabindex directly set to 1, do not accept the TAB key events,

CodePudding user response:

reference exception92 reply: 3/f
record before the user choose the index of the line, again enters gotfocus judge whether the index is equal to zero, not equal to zero for selected=false Settings,
Or consider the tabindex directly set to 1, do not accept the TAB key events,

Enter GotFocus event, select rows in fact has been on the first line, automatic judgment choose line at that time is the first row, so can't distinguish user to select the first line of the automatically placed in the first row,
Tabstop set to False, the user can't use the keyboard operation,
  • Related