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

注解

如果的trueSystem.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 窗体控件不是可选择的,将返回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.

适用于

另请参阅