Control.CanSelect Property
Gets a value indicating whether the control can be selected.
[Visual Basic] Public ReadOnly Property CanSelect As Boolean [C#] public bool CanSelect {get;} [C++] public: __property bool get_CanSelect(); [JScript] public function get CanSelect() : Boolean;
Property Value
true if the control can be selected; otherwise, false.
Remarks
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.
- Panel
- GroupBox
- PictureBox
- ProgressBar
- Splitter
- Label
- LinkLabel (when there is no link present in the control)
Example
[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 control.Select() End If End Sub [C#] public void ControlSelect(Control control) { // Select the control, if it can be selected. if(control.CanSelect) { control.Select(); } } [C++] public: void ControlSelect(Control* control) { // Select the control, if it can be selected. if (control->CanSelect) { control->Select(); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
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