System.Windows.Forms.TextBoxBase.Select Method

Selects a range of text in the text box.

Syntax

public void Select (int start, int length)

Parameters

start
The position of the first character in the current text selection within the text box.
length
The number of characters to select.

Remarks

If you want to set the start position to the first character in the control's text, set the start parameter to 0. You can use this method to select a substring of text, such as when searching through the text of the control and replacing information.

Note:

You can programmatically move the caret within the text box by setting the start parameter to the position within the text box where you want the caret to move to and set the length parameter to a value of zero (0). The text box must have focus in order for the caret to be moved.

Note:

If this method is called without any parameters, an alternative method is used. This alternative method inherits from the System.Windows.Forms.Control class. When called, it sets the input focus to the control and selects the contents of the control. For more information, see the Control.Select method.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0