Is there a simple way to suppress an event from firing when changing the value of a control? Specifically I have an Action event handler attached to a Checkbox, but I’d like to avoid running the handler when I initialize the value of the checkbox.
Usually you would do that by setting a flag somewhere and checking that flag in the event.
One major case in point (and this bit me big time the other day)… and its really kind of not even a “event” by the standard definition.
But Computed Property SETTERS will fire prior to the OPEN event. This causes all kinds of havoc if you have that setter update a control if the property changed… since that control may not even exist during the initialization sequence. So I had to use a flag, that was ultimately set to TRUE in the ACTIVATE event…
In the open event do:
isOpening = true
'do you stuff
isOpening = false
In the value changed event do:
if isOpening then return
'do other stuff
OK - at first I was thinking that would be complicated since I need to ensure that the flag is reset properly every time the value is changed programmatically, but I’ll just create a setter method that handles the flag. Thanks all!
There are some things that you’d want to evaluate on a control value change whether it was by user or by code. An event should always fire for predictability and reliability. It is on the developer to decide whether or not they need to evaluate anything in the event. If you don’t need it, exit early like Kem and Beatrix suggest.