Version

SelectionStart Property (XamMaskedEditor)

Indicates the start location of the selected text. If no text is selected, this property indicates the location of the caret.
Syntax
'Declaration
 
Public Property SelectionStart As Integer
public int SelectionStart {get; set;}
Example
The following code demonstrates various selection related properties of the XamMaskedEditor.

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.maskedEditor1.StartEditMode()

    ' Select 3 characters starting from character position 4.
    Me.maskedEditor1.SelectionStart = 4
    Me.maskedEditor1.SelectionLength = 3

    Dim selectedText As String = Me.maskedEditor1.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.maskedEditor1.SelectedText = "222"

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

    ' The following two lines perform the same operation as SelectAll.
    ' TextLength property returns the number of display characters 
    ' (character placeholders) in the masked editor, regardless of whether
    ' they are empty or filled in.
    Me.maskedEditor1.SelectionStart = 0
    Me.maskedEditor1.SelectionLength = Me.maskedEditor1.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.maskedEditor1.StartEditMode( );

	// Select 3 characters starting from character position 4.
	this.maskedEditor1.SelectionStart = 4;
	this.maskedEditor1.SelectionLength = 3;

	string selectedText = this.maskedEditor1.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.maskedEditor1.SelectedText = "222";

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

	// The following two lines perform the same operation as SelectAll.
	// TextLength property returns the number of display characters 
	// (character placeholders) in the masked editor, regardless of whether
	// they are empty or filled in.
	this.maskedEditor1.SelectionStart = 0;
	this.maskedEditor1.SelectionLength = this.maskedEditor1.TextLength;
}
<igEditors:XamMaskedEditor 
    
x:Name="maskedEditor1" 
    
Mask="###-###-###" 
    
Value="111-111-111" 
    
/>
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