Control.CanSelect Control.CanSelect Control.CanSelect Control.CanSelect Property

定義

取得指示能否選取控制項的值。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,否則為 falsetrue 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

備註

true 如果的System.Windows.Forms.ControlStyles值設定為true、包含在另一個控制項中、控制項本身為可見且已啟用,而且其所有父控制項都為可見和啟用,則這個屬性會傳回。 SelectableThis 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 控制項無法選取,而且將會傳回false CanSelect屬性的值。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.

適用於

另請參閱