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如果Selectable的值System.Windows.Forms.ControlStyles设置为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 窗体控件不是可选择并将返回的值falseCanSelect属性。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.

适用于

另请参阅