| PowerBuilder - ItemChanged Not Firing |
Josef Dufek (vondr@issbrno.anet.cz) wrote:
: Hi,
: I have a grid datawindow. In the clicked event I call a response window and
: returned parameters I want to assign into 3 columns.
: 1.
: I call SetItem() and then AcceptText() in the Clicked event but ItemChanged
: event is not triggerred.
: (PB Help: AcceptText may trigger an ItemChanged or an ItemError event.)
AcceptText() does not, in and of itself, fire itemchanged. AcceptText's
role is to check to see if any user modifications are pending for the
current column, and if so validate the new data (including firing
itemchanged) and copy valid data into the underlying datawindow buffer.
Your problem here is that SetItem() modifies the dw buffer directly,
bypassing the user entry mechanism. AcceptText() has nothing to do,
and consequently itemchanged is not firing. Note most of this confusion
is due to the fact that itemchanged is kind of mis-named, since it doesn't
fire whenever the real data has changed, only when the user is attempting
to change the data (and not when it is changed programmatically, with
the following exception).
You can get it to fire by using SetColumn(), SetText(), and AcceptText(),
because SetText() simulates user entry, but doesn't change the underlying
data until the column focus changes or AcceptText() is called. You can
also use SetColumn(), SetText(), and then manually fire itemchanged, but
I don't recommend that approach.
This is usually caused by having a MessageBox() call in the itemchanged
event, possibly in conjunction with AcceptText() in the LoseFocus event.
It is usually best to avoid having MessageBox calls in this event. Instead,
set the validation error message dynamically:
this.Modify("colname.ValidationMsg='Invalid date'")
HTH
Simon
--
All views expressed in this message are my own and not necessarily those of
my employer
"mahenn" <mahenn45@hotmail.com> wrote in message
news:QNOZSswsBHA.204@forums.sybase.com...
> Hi All,
> I ran into a strange situation. I had code in the itemchanged event of
a dw,
> which bascially checks for a valid date. I used a RETURN 1 if the date
was
> invalid. The problem is the event fires correctly during the DEBUG mode
and
> displays the error message, but if I run the program as is, I get the
message
> first time but allows the focus to change to a different column.
> Any suggestions what might be missing.
> TIA
The problem I am having is that the when an item fails validation I will
> get the same error messagebox twice. The reason is that the AcceptText
will
> call the itemchanged event and the pressing of the enter key will by
> default call the itemchanged event, so I end up calling the itemchanged
> event twice. The itemchanged event from the AcceptText will execute first
> and then the itemchanged event from the user pressing enter will execute
> last.
| Source : | Listing1 |
| Author : | Jason Vogel |
| References Links : | http://www.poboxes.com/jasonvogel |
| Source | empty |
|
Copyright © : 1997 - 2004 |