Determines the total number of characters in the selected text in an editable control, including spaces and line endings.
DataWindow, EditMask, MultiLineEdit, SingleLineEdit, RichTextEdit, DropDownListBox, and DropDownPictureListBox controls
editname.SelectedLength ( )
Argument |
Description |
---|---|
editname |
The name of the control in which you want the length of the selected text. For a DataWindow, it reports the length of the selected text in the edit control over the current row and column. |
Long. Returns the length of the selected text in editname. If no text is selected, SelectedLength returns 0. If an error occurs, it returns -1. If editname is null, SelectedLength returns null.
The characters that make up a line ending, produced by typing Ctrl+Enter or Enter, is different on different platforms. On Windows, it is a carriage return plus a line feed and equals two characters when calculating the length. On other platforms, a line ending is a single character. A line that has wrapped has no line-ending character. For DropDownListBox and DropDownPictureListBox controls, SelectedLength returns -1 if the control’s AllowEdit property is set to false.
Focus and the selection in a drop-down list When a DropDownListBox or DropDownPictureListBox loses focus, the selected text is no longer selected.
If the selected text in the MultiLineEdit mle_Contact is John Smith, then this example sets li_length to 10:
integer li_length
li_length = mle_Contact.SelectedLength()