This documentation is archived and is not being maintained.

Control.CanSelect Property

Gets a value indicating whether the control can be selected.

[Visual Basic]
Public ReadOnly Property CanSelect As Boolean
public bool CanSelect {get;}
public: __property bool get_CanSelect();
public function get CanSelect() : Boolean;

Property Value

true if the control can be selected; otherwise, false.


This property returns true if the control has ControlStyles.Selectable set to true, is contained in another control, and all its parent controls are both visible and enabled.

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.


[Visual Basic, C#, C++] The following example selects the specified Control, if it is selectable.

[Visual Basic] 
Public Sub ControlSelect(control As Control)
   ' Select the control, if it can be selected.
   If control.CanSelect Then
   End If
End Sub

public void ControlSelect(Control control)
   // Select the control, if it can be selected.

   void ControlSelect(Control* control) {
      // Select the control, if it can be selected.
      if (control->CanSelect) {

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | Select | Enabled | Visible | Focus | CanFocus