Export (0) Print
Expand All

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)

'Declaration
Public Property SelectionStart As Integer
<TextBox SelectionStart="int"/>

Property Value

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

ExceptionCondition
ArgumentOutOfRangeException

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 Sub 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
End Sub


Silverlight

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

ADD
Show:
© 2014 Microsoft