Control.Focused Control.Focused Control.Focused Control.Focused Property


コントロールに入力フォーカスがあるかどうかを示す値を取得します。Gets a value indicating whether the control has input focus.

 virtual property bool Focused { bool get(); };
public virtual bool Focused { get; }
member this.Focused : bool
Public Overridable ReadOnly Property Focused As Boolean


コントロールにフォーカスがある場合は true。それ以外の場合は falsetrue if the control has focus; otherwise, false.

次のコード例を無効にするMenuItem場合、TextBoxにフォーカスがないです。The following code example disables a MenuItem if a TextBox does not have focus. この例が必要です、Formで、TextBoxというtextBox1と 2 つMenuItemという名前のオブジェクトmenuItemEditmenuItemEditInsertCustomerInfoThis example requires that you have a Form with a TextBox named textBox1 and two MenuItem objects named menuItemEdit and menuItemEditInsertCustomerInfo.

   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

注意 (継承者)

オーバーライドする場合、 Focused 、派生クラスでプロパティを使用して、基本クラスのFocused基本実装を拡張するプロパティ。When overriding the Focused property in a derived class, use the base class's Focused property to extend the base implementation. それ以外の場合、すべての実装を提供する必要があります。Otherwise, you must provide all the implementation.