Syntax 1 For DataWindows with standard edit styles
Description
Selects text in an editable control. You specify where the
selection begins and how many characters to select.
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataWindow control |
Web ActiveX |
DataWindow control |
Syntax
[PowerBuilder]
1 |
long <span>dwcontrol</span>.<span>SelectText</span> ( long <span>start</span>, long <span>length</span> ) |
[Web ActiveX]
1 |
number <span>dwcontrol</span>.<span>SelectText</span> ( number <span>start</span>, number <span>length</span> ) |
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control. |
start |
A numeric value specifying the position |
length |
A numeric value specifying the number |
Return Values
Returns the number of characters selected. If an error occurs, SelectText returns –1.
If any argument’s value is null, in PowerBuilder
and JavaScript the method returns null.
Usage
If the control does not have the focus when you call SelectText,
then the text is not highlighted until the control has focus. To
set focus on the control so that the selected text is highlighted,
call the SetFocus function.
To select text in a DataWindow with the RichTextEdit presentation
style, use Syntax 2.
For use with other PowerBuilder controls, see SelectText in
the PowerScript Reference.
Examples
This statement sets the insertion point at the end
of the text in the DataWindow edit control:
1 |
dw_1.<span>SelectText</span>(dw_1.GetText(), 0) |
This statement selects the entire contents of the
DataWindow edit control:
1 |
dw_1.<span>SelectText</span>(1, Len(dw_1.GetText())) |
The rest of these examples assume the DataWindow
edit control contains Boston Street.
The following statement selects the string ost and returns
3:
1 |
dw_1.<span>SelectText</span>(2, 3) |
The next statement selects the string oston Street
and returns 12:
1 |
dw_1.<span>SelectText</span>(2, Len(dw_1.GetText())) |
These statements select the string Bos, returns 3,
and sets the focus to the DataWindow control so that Bos is highlighted:
1 |
dw_1.<span>SelectText</span>(1, 3) |
1 |
dw_1.SetFocus() |