Control.CanSelect 属性

获取一个值,该值指示是否可以选中控件。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public ReadOnly Property CanSelect As Boolean
用法
Dim instance As Control
Dim value As Boolean

value = instance.CanSelect
public bool CanSelect { get; }
public:
property bool CanSelect {
    bool get ();
}
/** @property */
public boolean get_CanSelect ()
public function get CanSelect () : boolean

属性值

如果控件可以选中,则为 true;否则为 false

备注

如果满足以下所有条件,此属性将返回 trueSystem.Windows.Forms.ControlStylesSelectable 值设置为 true:控件包含在另一个控件中;控件本身可见且已启用;控件的所有父控件可见且已启用。

下面的列表中的 Windows 窗体控件不可选择,且将为 CanSelect 属性返回 false 值。从这些控件派生的控件也是不可选择的。

示例

下面的代码示例在指定的 Control 可选择的情况下选择它。

Public Sub ControlSelect(control As Control)
   ' Select the control, if it can be selected.
   If control.CanSelect Then
      control.Select()
   End If
End Sub
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 void ControlSelect(Control control)
{
    // Select the control, if it can be selected.
    if (control.get_CanSelect()) {
        control.Select();
    }
} //ControlSelect

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Control 类
Control 成员
System.Windows.Forms 命名空间
Select
Enabled
Visible
Focus
Control.CanFocus 属性