tags:

views:

231

answers:

1

Within PB6.5.1 and PB9.0:

Question 1: In itemchanged event: return 1 In itemerror event: return 3 At runtime,the sequence of events fired is: itemchanged-->itemerror-->itemchanged-->itemerror Why is each event fired twice?

Question 2: In itemchanged event: return 1 In itemerror event: return 2 At runtime,the focus did not move to the next cell. Why?

Thanks.

+4  A: 

Question 1: By returning 3 from itemerror, you have rejected the data, which clears the column and triggers the itemchanged again.

As to philosophically why PowerBuilder is designed to work in this fashion, I suspect they thought it would follow the principal of least surprise i.e. they were anticipating people asking why rejecting the input did not trigger itemchanged.

Question 2: The itemchanged event overrides itemerror. In itemchanged you rejected the input and prevented focus changing; in itemerror you now accept the input, but you have not removed the block on focus changing. You should return 2 from itemchanged, since you can then control whether you allow focus to change from the itemerror event, by returning either 1 or 3.


In case anyone is reading this question without the powerbuilder help files handy:

return values for itemchanged:

0 (Default) Accept the data value
1 Reject the data value and do not allow focus to change (triggers itemerror)
2 Reject the data value but allow the focus to change (triggers itemerror)

return values for itemerror:

0 (Default) Reject the data value and show an error message box
1 Reject the data value with no message box
2 Accept the data value
3 Reject the data value but allow focus to change

Colin Pickard
Thanks for your answer.It looks not be mentioned in the PowerBuilder help that itemerror event returning 3 will trigger itemchanged event,doesn't it?
Relevant pages from the online docs (see ItemChanged and ItemError): http://infocenter.sybase.com/help/topic/com.sybase.dc37783_1150/html/dwref/BABCJGCA.htm
Dougman