Version

SelectionLength Property (XamTextEditor)

Gets or sets the length of the selected text. If nothing is selected then returns 0.
Syntax
'Declaration
 
Public Property SelectionLength As Integer
public int SelectionLength {get; set;}
Remarks

SelectionLength returns the length of the currently selected text. If nothing is currently selected then returns 0.

Setting this property will modify the text that's selected. It can be used to increase or decrease the amount of text that's currently selected. Setting it to 0 deselects the selected text. Note that setting this property does not modify the contents of the control.

Example
The following code demonstrates selection related properties of the XamTextEditor.

Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        ' Make sure the editor is in edit mode. The following operations
        ' are only valid during edit mode. You can set IsAlwaysInEditMode
        ' to True so this step is not necessary as the editor will always
        ' be in edit mode.
        Me.textEditor1.StartEditMode()

        Me.textEditor1.Value = "Test"

        ' Select 3 characters starting from character position 1.
        Me.textEditor1.SelectionStart = 1
        Me.textEditor1.SelectionLength = 3

        ' This will print out the selected text which is "est".
        Dim selectedText As String = Me.textEditor1.SelectedText
        Debug.WriteLine("SelectedText = " & selectedText)

        ' Setting the SelectedText will delete the selected text
        ' and in its place insert the specified text. If nothing
        ' is currently selected then the specified text will be 
        ' inserted at the caret location.
        Me.textEditor1.SelectedText = "EST"

        ' SelectAll will select all of the text.
        Me.textEditor1.SelectAll()

        ' The following two lines perform the same operation as SelectAll.
        ' TextLength property returns the length of text in the editor.
        Me.textEditor1.SelectionStart = 0
        Me.textEditor1.SelectionLength = Me.textEditor1.TextLength
    End Sub
public void button1_Click( object sender, RoutedEventArgs e )
{
	// Make sure the editor is in edit mode. The following operations
	// are only valid during edit mode. You can set IsAlwaysInEditMode
	// to True so this step is not necessary as the editor will always
	// be in edit mode.
	this.textEditor1.StartEditMode( );

	this.textEditor1.Value = "Test";

	// Select 3 characters starting from character position 1.
	this.textEditor1.SelectionStart = 1;
	this.textEditor1.SelectionLength = 3;

	// This will print out the selected text which is "est".
	string selectedText = this.textEditor1.SelectedText;
	Debug.WriteLine( "SelectedText = " + selectedText );

	// Setting the SelectedText will delete the selected text
	// and in its place insert the specified text. If nothing
	// is currently selected then the specified text will be 
	// inserted at the caret location.
	this.textEditor1.SelectedText = "EST";

	// SelectAll will select all of the text.
	this.textEditor1.SelectAll( );

	// The following two lines perform the same operation as SelectAll.
	// TextLength property returns the length of text in the editor.
	this.textEditor1.SelectionStart = 0;
	this.textEditor1.SelectionLength = this.textEditor1.TextLength;
}
<igEditors:XamTextEditor x:Name="textEditor1"  />
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also