SelectionStart Property

TextBox.SelectionStart Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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)
XMLNS for XAML: Not mapped to an xmlns.

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;

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft