Control.CanFocus Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Property Value
true
if the control can receive focus; otherwise, false
.
- Attributes
Examples
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
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기