New to Telerik UI for WinForms? Download free 30-day trial

Caret positioning and selection

The positioning and selection in RadAutoCompleteBox can be performed programmatically as well as by using the keyboard and mouse input.

To select items with the press the arrow keys while holding Shift.

Programmatic selection can be performed by using the SelectionStart and SelectionLength properties.

The SelectionStart property is an integer 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.

Setting the SelectionLength to a number greater than 0 causes that number of characters to be selected, starting from the current insertion point.

private void SetSelection()
    this.radAutoCompleteBox1.Text = "Pepsi; Sprite; Coca-Cola;";
    this.radAutoCompleteBox1.SelectionStart = 6;
    this.radAutoCompleteBox1.SelectionLength = 7;

Private Sub SetSelection()
    Me.RadAutoCompleteBox1.Text = "Pepsi; Sprite; Coca-Cola;"
    Me.RadAutoCompleteBox1.SelectionStart = 6
    Me.RadAutoCompleteBox1.SelectionLength = 7
End Sub

Alternatively, you can use the Select method to select the same part of the text:

private void SetSelectionRange()
    this.radAutoCompleteBox1.Text = "Pepsi;Sprite;Coca-Cola";
    this.radAutoCompleteBox1.Select(6, 7);

Private Sub SetSelectionRange()
    Me.RadAutoCompleteBox1.Text = "Pepsi;Sprite;Coca-Cola"
    Me.RadAutoCompleteBox1.[Select](6, 7)
End Sub

The both approaches produce same result:

WinForms RadAutoCompleteBox Select Text

See Also

In this article