# Caret positioning and selection

The positioning and selection in **RadTextBoxControl** can be performed programmatically as well as using keyboard and mouse input.

To select text you can press the shift key followed by left mouse button or one of the navigation keys of the keyboard (up, down, left, right buttons).

Programmatically selection can be performed by using the **SelectionStart** and **SelectionLength** properties of RadTextBoxControl.

The **SelectionStart** property is a number that indicates the insertion point within the string of text, with 0 being the left-most position. If the **SelectionStart** property is set to a value equal to or greater than the number of characters in the text box, the insertion point is placed after the last character.

The **SelectionLength** property is a numeric value that sets the width of the insertion point. Setting the **SelectionLength** to a number greater than 0 causes that number of characters to be selected, starting from the current insertion point.

#### Select part of the text using the **SelectionStart** and **SelectionLenght** properties.

```C#
private void SetSelection()
{
    this.radTextBoxControl1.Text = "Hello, John Green";
    this.radTextBoxControl1.SelectionStart = 7;
    this.radTextBoxControl1.SelectionLength = 4;
}

```

```VB.NET
Private Sub SetSelection()
    Me.RadTextBoxControl1.Text = "Hello, John Green"
    Me.RadTextBoxControl1.SelectionStart = 7
    Me.RadTextBoxControl1.SelectionLength = 4
End Sub
```

#### Use the **Select** method to select the part of the text:

```C#
private void SelectText()
{
    this.radTextBoxControl1.Text = "Hello, John Green";
    this.radTextBoxControl1.Select(7, 4);
}

```

```VB.NET
Private Sub SelectText()
    Me.RadTextBoxControl1.Text = "Hello, John Green"
    Me.RadTextBoxControl1.[Select](7, 4)
End Sub
```

The both approaches produce same result:

![WinForms RadTextBoxControl Caret Position Selection](https://www.telerik.com/products/winforms/documentation/assets/13a2c52ce59d7563b972f3e8833566dd/editors-textboxcontrol-caret-positioning-and-selection001.png)

You can access the selected text through the **SelectedText** property. To select the whole text use the **SelectAll** method.

Note that you can use the **CaretIndex** property to move the caret at specified position and clear the selection.

## See Also

* [AutoComplete](https://www.telerik.com/products/winforms/documentation/controls/editors/textboxcontrol/autocomplete)
* [Creating custom blocks](https://www.telerik.com/products/winforms/documentation/controls/editors/textboxcontrol/creating-custom-blocks)
* [Structure](https://www.telerik.com/products/winforms/documentation/controls/editors/textboxcontrol/element-structure-and-document-object-model)
* [Properties and Events](https://www.telerik.com/products/winforms/documentation/controls/editors/textboxcontrol/properties)
* [Text editing](https://www.telerik.com/products/winforms/documentation/controls/editors/textboxcontrol/text-editing)
