Control.CanFocus プロパティ
定義
コントロールがフォーカスを受け取ることができるかどうかを示す値を取得します。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
プロパティ値
コントロールがフォーカスを受け取ることができる場合は true
。それ以外の場合は false
。true
if the control can receive focus; otherwise, false
.
- 属性
例
次のコード例では、フォーカスを Control 受け取ることができる場合に、指定されたにフォーカスを設定します。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
注釈
コントロールが入力フォーカスを受け取るには、コントロールにハンドルが割り当てられている必要があります。また、コントロール Visible Enabled とそのすべての親コントロールに対して、プロパティとプロパティの両方がに設定されている必要があります。また、コントロールがフォームである true
か、コントロールの最も外側の親がフォームである必要があります。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.