편집

다음을 통해 공유


Control.CanFocus Property

Definition

Gets a value indicating whether the control can receive focus.

public:
 property bool CanFocus { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool CanFocus { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CanFocus : bool
Public ReadOnly Property CanFocus As Boolean

Property Value

true if the control can receive focus; otherwise, false.

Attributes

Examples

The following code example sets focus to the specified Control, if it can receive focus.

public:
   void ControlSetFocus( Control^ control )
   {
      
      // Set focus to the control, if it can receive focus.
      if ( control->CanFocus )
      {
         control->Focus();
      }
   }
public void ControlSetFocus(Control control)
{
   // Set focus to the control, if it can receive focus.
   if(control.CanFocus)
   {
      control.Focus();
   }
}
Public Sub ControlSetFocus(control As Control)
   ' Set focus to the control, if it can receive focus.
   If control.CanFocus Then
      control.Focus()
   End If
End Sub

Remarks

In order for a control to receive input focus, the control must have a handle assigned to it, and the Visible and Enabled properties must both be set to true for both the control and all its parent controls, and the control must be a form or the control's outermost parent must be a form.

Applies to

See also