System.Windows.Forms.Control.Focus Method

Sets input focus to the control.


public bool Focus ()


true if the input focus request was successful; otherwise, false.


The Control.Focus method returns true if the control successfully received input focus. The control can have the input focus while not displaying any visual cues of having the focus. This behavior is primarily observed by the nonselectable controls listed below, or any controls derived from them.

A control can be selected and receive input focus if all the following are true: the Selectable value of System.Windows.Forms.ControlStyles is set to true, it is contained in another control, and all its parent controls are both visible and enabled.

The Windows Forms controls in the following list are not selectable. Controls derived from these controls are also not selectable.


Control.Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Control.Select method or the ContainerControl.ActiveControl property for child controls, or the Form.Activate method for forms.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,