SelLength: Integer;
The SelLength property determines the number of characters selected in the component text.
When the SelLength property value is obtained, the number of characters selected in the component will be returned.
When the SelLength property value is set, the determined number of characters are selected. The selection begins with the position where the cursor (SelStart) is set. If value of SelLength is positive, text is selected to the right of the cursor, if the value is negative, it is selected to the left of the cursor. After selection, the SelStart cursor position will not be changed.
Executing the example requires a form with the button named Button1 on it and the ExpressionEdit component named ExpressionEdit1.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
If ExpressionEdit1.SelText = "" Then
ExpressionEdit1.SelStart := 2;
ExpressionEdit1.SelLength := 4;
ExpressionEdit1.SetFocus;
End If;
End Sub Button1OnClick;
On clicking the button, if there is no selected text in the ExpressionEdit1 component, the selection is executed: starting with the third character, four characters will be selected. After that the component will get the focus.
See also: