Control.Focused プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
コントロールに入力フォーカスがあるかどうかを示す値を取得します。
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
プロパティ値
true コントロールにフォーカスがある場合。それ以外の場合は false。
- 属性
例
次のコード例では、TextBoxにフォーカスがない場合にMenuItemを無効にします。 この例では、textBox1 という名前のTextBoxと、menuItemEdit と menuItemEditInsertCustomerInfo という名前の 2 つのMenuItem オブジェクトを持つFormが必要です。
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
注意 (継承者)
派生クラスの Focused プロパティをオーバーライドする場合は、基底クラスの Focused プロパティを使用して基本実装を拡張します。 それ以外の場合は、すべての実装を指定する必要があります。