SetText – PB Docs 2017

SetText

method (DataWindows)

Description

Replaces the text in the edit control over the current row and
column in a DataWindow control or DataStore.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataStore object

Syntax

PowerBuilder

Argument

Description

dwcontrol

The name of the DataWindow control or DataStore in
which you want to specify the text in the current row and
column.

text

A string whose value you want to put in the current
row and column. The value must be compatible with the datatype of
the column.

Return value

Returns 1 if it succeeds and -1 if an error occurs. If any
argument’s value is null, in PowerBuilder and JavaScript the method
returns null.

Usage

SetText only sets the value in the edit control. When the user
changes focus to another row and column, PowerBuilder accepts the text as
the item in the row and column.

Using SetText in the ItemChanged and ItemError events

In the ItemChanged or ItemError event, PowerBuilder or your own
script might determine that the value in the edit control is invalid or
that it needs further processing. You can call SetItem to specify a new
item value for the row and column.

If you want the user to have an opportunity to enter a different
value, after calling SetItem you can call SetText to put that same value
in the edit control so that the user sees the value too. You can also call
SetText without calling SetItem. In the script, use a return code that
rejects the value in the edit control, avoiding further processing, but
does not allow the focus to change. To retain focus and display an error
message, return 1 for ItemChanged or 0 for ItemError.

When you use a return code that rejects the data the user entered
but allows the focus to change (a return code of 2 in the script for the
ItemChanged event or 3 in the ItemError event), you do not need to call
SetText because the value set with SetItem displays when the focus
changes.

Examples

These statements replace the value of the current row and column in
dw_employee with Tex and then call AcceptText to accept and move Tex into
the current column. (Do not use this code in the ItemChanged or ItemError
event because it calls AcceptText.)

This example converts a number that the user enters in the column
called credit to a negative value and sets both the item and the edit
control’s text to the negative number. This code is the script for the
ItemChanged event. The data argument holds the newly entered value:

See also

AcceptText

GetText

SetItem


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x