In WinForms, to set focus to a specific control, I always seem to wind up calling Control.Select()
and Control.Focus()
to get it to work.
What is the difference, and is this the correct approach?
See Question&Answers more detail:osIn WinForms, to set focus to a specific control, I always seem to wind up calling Control.Select()
and Control.Focus()
to get it to work.
What is the difference, and is this the correct approach?
See Question&Answers more detail:osFocus() is the low level function that actually sets the focus.
Select() is a higer-level method. It first looks iteratively upward in the control's parent hierarchy until it finds a container control. Then it sets that container's ActiveControl property (to the called control). The logic in those methods is not straightforward however, and there is special handling for UserControl containers.