SetSel - DfBaseRichEdit
Selects text in given position range
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| iPositionStart | integer | The starting position of the text |
| iPositionEnd | integer | The ending position of the text |
Syntax
Procedure SetSel integer iPositionStart integer iPositionEnd
Call Example
Send SetSel iPositionStart iPositionEnd
Description
Selects text in control in given position range.
Selects text from character immediately after position iPositionStart to character in the position iPositionEnd.
If iPositionStart is equal to iPositionEnd, the selection range is empty, so caret will be placed immediately after position iPositionStart. If iPositionStart is equal to 0, and iPositionEnd is -1, the entire text is selected.
The character position is the zero-based absolute position of the character in the control. The first position in the first line is always 0. If the first line in the control contains 20 characters, the first position in the second line will be 20.
This method has no effect if control is not paged.
Sample
This sample selects (highlights) the text in control oRichEdit1.
Procedure DoSearch
Integer iSelStart iSelEnd
Move 0 to iSelStart
Move 20 to iSelEnd
Send SetSel of oRichEdit1 iSelStart iSelEnd
End_Procedure
Sample
This sample performs a case-sensitive search for "Joe" in the oRichEdit1 control using the FindText method. If "Joe" appears in the portion of the control's text that is searched, it is selected using SetSel. This sample assumes that a Form or dbForm control named oSearchText exists in your code.
| Col 1 | Col 2 |
|---|---|
| Note: | A more sophisticated version of this sample can be found in the FindText method documentation. |
Procedure DoSearch
integer iSelStart iSelEnd
get FindText of oRichEdit1 "Joe" FR_MATCHCASE to iSelStart
// was search successful?
if (iSelStart <> -1) begin
// get length of search text
move (length(sSearchText) + iSelStart) to iSelEnd
// select search text found
send SetSel of oRichEdit1 iSelStart iSelEnd
end
End_Procedure // DoSearch