SelectRow  SelectTextAll

Chapter 9: Methods for the DataWindow Control

SelectText

Selects text in an edit control.

To select text in

Use

A DataWindow when the DataWindow does not have the RichTextEdit presentation style

Syntax 1 For DataWindows with standard edit styles

A DataWindow whose object has the RichTextEdit presentation style (PowerBuilder only)

Syntax 2 For RichTextEdit DataWindows


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.

Syntax

long dwcontrol.SelectText ( long start, long length )

Argument

Description

dwcontrol

A reference to a DataWindow control.

start

A numeric value specifying the position at which you want to start the selection.

length

A numeric value specifying the number of characters you want to select. If length is 0, no text is selected but SelectText moves the insertion point to the location specified in start.

Returns

Returns the number of characters selected. If an error occurs, SelectText returns -1. If any argument’s value is NULL, 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.

NoteUsing with other PocketBuilder controls For use with other controls, see SelectText in the PowerScript Reference.

Examples

Example 1

This statement sets the insertion point at the end of the text in the DataWindow edit control:

dw_1.SelectText(dw_1.GetText(), 0)

Example 2

This statement selects the entire contents of the DataWindow edit control:

dw_1.SelectText(1, Len(dw_1.GetText()))

Example 3

The rest of these examples assume the DataWindow edit control contains Boston Street.

The following statement selects the string ost and returns 3:

dw_1.SelectText(2, 3)

Example 4

The next statement selects the string oston Street and returns 12:

dw_1.SelectText(2, Len(dw_1.GetText()))

Example 5

These statements select the string Bos, returns 3, and sets the focus to the DataWindow control so that Bos is highlighted:

dw_1.SelectText(1, 3)

dw_1.SetFocus()

See also


Syntax 2 For RichTextEdit DataWindows

Description

Selects text beginning and ending at a line and character position in a RichText DataWindow.

Syntax

PowerBuilder

long rtedwcontrol.SelectText ( long fromline, long fromchar, long toline, long tochar { band band } )

Returns

Returns the number of characters selected. If an error occurs it returns -1. If any argument’s value is NULL, SelectText returns NULL.





Copyright © 2004. Sybase Inc. All rights reserved. SelectTextAll

View this book as PDF