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,否則為 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

備註

如果 System.Windows.Forms.ControlStylesSelectable 值設定為 true、包含在另一個控制項中,控制項本身會顯示並啟用,而且其所有父控制項都是可見和啟用的,則這個屬性會傳回 trueThis 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.

適用於

另請參閱