Control.CanSelect 屬性
定義
取得指示能否選取控制項的值。Gets a value indicating whether the control can be selected.
public:
property bool CanSelect { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool CanSelect { get; }
member this.CanSelect : bool
Public ReadOnly Property CanSelect As Boolean
屬性值
如果可以選取控制項,則為 true
,否則為 false
。true
if the control can be selected; otherwise, false
.
- 屬性
範例
下列程式碼範例會選取指定的 Control(如果可選取)。The following code example selects the specified Control, if it is selectable.
public:
void ControlSelect( Control^ control )
{
// Select the control, if it can be selected.
if ( control->CanSelect )
{
control->Select( );
}
}
public void ControlSelect(Control control)
{
// Select the control, if it can be selected.
if(control.CanSelect)
{
control.Select();
}
}
Public Sub ControlSelect(control As Control)
' Select the control, if it can be selected.
If control.CanSelect Then
control.Select()
End If
End Sub
備註
如果 System.Windows.Forms.ControlStyles 的 Selectable
值設定為 true
、包含在另一個控制項中、控制項本身為可見且已啟用,而且其所有父控制項都為可見和啟用,這個屬性就會傳回 true
。This property returns true
if the Selectable
value of System.Windows.Forms.ControlStyles is set to true
, is contained in another control, the control itself is visible and enabled, and all its parent controls are visible and enabled.
下列清單中的 Windows Forms 控制項無法選取,而且將會傳回 CanSelect 屬性的 false
值。The Windows Forms controls in the following list are not selectable and will return a value of false
for the CanSelect property. 這些控制項衍生的控制項也無法選取。Controls derived from these controls are also not selectable.