Control.Focused Właściwość

Definicja

Pobiera wartość wskazującą, czy kontrolka ma fokus wejściowy.

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

Wartość właściwości

true jeśli kontrolka ma fokus; w przeciwnym razie , false.

Atrybuty

Przykłady

Poniższy przykład kodu wyłącza funkcję MenuItem , jeśli element nie ma fokusu TextBox . W tym przykładzie wymagany jest Form obiekt o TextBox nazwie i dwóch MenuItem obiektach o nazwach textBox1menuItemEdit i menuItemEditInsertCustomerInfo.

private:
   void menuItemEdit_Popup( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      // Disable the menu item if the text box does not have focus.
      this->menuItemEditInsertCustomerInfo->Enabled = this->textBox1->Focused;
   }
private void menuItemEdit_Popup(object sender, EventArgs e)
{
   // Disable the menu item if the text box does not have focus.
   this.menuItemEditInsertCustomerInfo.Enabled = this.textBox1.Focused;
}
Private Sub menuItemEdit_Popup(sender As Object, _
  e As EventArgs) Handles menuItemEdit.Popup
   ' Disable the menu item if the text box does not have focus.
   Me.menuItemEditInsertCustomerInfo.Enabled = Me.textBox1.Focused
End Sub

Uwagi dotyczące dziedziczenia

Podczas zastępowania Focused właściwości w klasie pochodnej użyj właściwości klasy Focused bazowej, aby rozszerzyć implementację podstawową. W przeciwnym razie należy podać całą implementację.

Dotyczy

Zobacz też