SelLength, SelStart, SelText
These three properties control selected text in those controls where textual entry is permitted: text boxes, edit boxes, spinners and combo boxes. You can figure out what the user highlighted or you can highlight text programmatically.
Usage |
oObject.SelLength = nNumCharsHighlighted nNumCharsHighlighted = oObject.SelLength oObject.SelStart = nFirstCharHighlighted nFirstCharHighlighted = oObject.SelStart oObject.SelText = cCharsHighlighted cCharsHighlighted = oObject.SelText |
Spinners act really weird. If you type into a spinner, the digits aren't all the way against the arrows. If you highlight some of the text you've typed while you're still there, it becomes SelText, but as soon as you tab out of the spinner, the text you typed moves to the right and SelText changes to the characters now in the position specified by SelStart and SelLength. |
It's okay that you can't change these properties for combos set up as drop-down lists. What's not okay is that they don't tell you anything in that case. They should provide the information about the currently selected item. |
Example |
* Change the current selection of a control * to lowercase. Assume we're in a method of * the control. This.SelText = LOWER(This.SelText) * Highlight the 5th through 10th characters * of edit box EDIT1 on the current form ThisForm.Edit1.SelStart = 5 ThisForm.Edit1.SelLength = 6 |
See Also |