Control.CanFocus Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob das Steuerelement den Fokus erhalten kann.

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

Eigenschaftswert

truewenn das Steuerelement den Fokus erhalten kann; andernfalls . false

Attribute

Beispiele

Im folgenden Codebeispiel wird der Fokus auf den angegebenen ControlWert festgelegt, wenn er den Fokus empfangen kann.

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

Hinweise

Damit ein Steuerelement den Eingabefokus erhält, muss ihm ein Handle zugewiesen sein, und die Visible Eigenschaften Enabled müssen sowohl für das Steuerelement als auch für alle übergeordneten Steuerelemente festgelegt true sein, und das Steuerelement muss ein Formular oder das übergeordnete Element des Steuerelements sein.

Gilt für:

Weitere Informationen