TextBox.SelectionStart Property

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

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

public int SelectionStart { get; set; }
<TextBox SelectionStart="int"/>

Property Value

Type: System.Int32
The starting position of the current selection.


The value is less than 0.

If there is no selection, the SelectionStart value gets or sets the location of the cursor.

Setting this value changes the starting position of the selection box and raises a SelectionChanged event. The SelectionLength remains the same.

The following code example shows how you can use the SelectionStart property.

private void SelectionStart()
    MyTB1.Select(3, 2);

    //The starting position of the cursor is set to the fifth position. Note that the 
    //SelectionLength remains the same when the text is selected.
    MyTB1.SelectionStart = 5;


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions