Control.CanSelect 屬性

定義

取得指示能否選取控制項的值。

public:
 property bool CanSelect { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool CanSelect { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CanSelect : bool
Public ReadOnly Property CanSelect As Boolean

屬性值

Boolean

如果可以選取控制項,則為 true,否則為 false

屬性

範例

下列程式碼範例會選取指定的 Control ,如果它是可選取的。

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

備註

如果 Selectable 的值設定 true 為 ,則此屬性會傳回 true ,其值 System.Windows.Forms.ControlStyles 包含在另一個控制項中、控制項本身為可見且已啟用,而且其所有父控制項都是可見且啟用的。

下列清單中的Windows Forms控制項無法選取,而且會傳 CanSelect 回 屬性的值 false 。 衍生自這些控制項的控制項也無法選取。

適用於

另請參閱