From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Property (As Integer )
aTextEdit.SelectionLength = newIntegerValue
IntegerValue = aTextEdit.SelectionLength

New in 2019r2

Supported for all project types and targets.

The number of selected characters.


A SelectionLength of 0 means an insertion point rather than a selection. A value greater than the number of characters in the control means that the selection is from SelectionStart to the end of the control.

On Windows, selecting text via code does not display the text as selected unless the control has the focus. If you want this behavior, call SetFocus before setting the selection.


This example selects the first 10 characters of TextArea1.

TextArea1.SelectionStart = 0
TextArea1.SelectionLength = 10