Replaces the text in the edit control over the current row and column in a DataWindow control or DataStore.
integer dwcontrol.SetText ( string text )
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. |
Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, the method returns NULL.
SetText only sets the value in the edit control. When the user changes focus to another row and column, PocketBuilder accepts the text as the item in the row and column.
In the ItemChanged or ItemError event, PocketBuilder or your own script might determine that the value in the edit control is invalid or needs further processing. You can call SetItem to specify a new item value for the row and column. After calling SetItem, you can call SetText to put that same value in the edit control so that the user also sees the value. In the script, use a return code that rejects the value in the edit control, avoiding further processing, and allow the focus to change. (Return 2 for ItemChanged and 3 for ItemError.)
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.)
dw_employee.SetText("Tex")
dw_employee.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:
integer negative
IF dwo.Name = "credit" THEN
IF Integer(data) > 0 THEN
// Convert to negative if it's positive
negative = Integer(data) * -1
// Change the primary buffer value.
This.SetItem(row, "credit", negative)
// Change the value in the edit control
This.SetText(String(negative))
RETURN 2
END IF
END IF
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |