System.Windows.Forms.TextBoxBase.SelectionStart Property

Gets or sets the starting point of text selected in the text box.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public int SelectionStart { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

If no text is selected in the control, this property indicates the insertion point, or caret, for new text. If you set this property to a location beyond the length of the text in the control, the selection start position will be placed after the last character. When text is selected in the text box control, changing this property might decrease the value of the TextBoxBase.SelectionLength property. If the remaining text in the control after the position indicated by the TextBoxBase.SelectionStart property is less than the value of the TextBoxBase.SelectionLength property, the value of the TextBoxBase.SelectionLength property is automatically decreased. The value of the TextBoxBase.SelectionStart property never causes an increase in the TextBoxBase.SelectionLength property.

You can programmatically move the selection within the text box by setting the TextBoxBase.SelectionStart and the TextBoxBase.SelectionLength properties.

You can programmatically move the caret within the text box by setting the TextBoxBase.SelectionStart to the position within the text box where you want the caret to move to and set the TextBoxBase.SelectionLength property to a value of zero (0).

The System.Windows.Forms.TextBox must have focus in order for the selection or the caret to be moved. You can set the TextBoxBase.SelectionStart property of a System.Windows.Forms.TextBox that is TextBoxBase.ReadOnly by giving it the Control.Focus first.

Requirements

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