Suspending all control events for a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with a bunch (maybe 30) different controls that generate events
when changed, clicked, etc. The various event handlers in turn might change
some of these controls, thereby causing other events, which is not what I
want. So, is there a simple way to turn off all events for a particular
form, then turn them all back on? I know I can individually turn them off
and on by using -= and += but that seems like a pretty brutal thing to have
to do. There should be some simple soultion like the equivalent of "disable
interrupts" and "enable interrupts".

Thanks,
Ray
 
Some controls offer BeginUpdate / EndUpdate pairs that sometimes do
this - but in general a form-level "isUpdating" variable (bool) might
be in order. Not very elegant, but it works.

Marc
 
Ray,

No, there isn't. You have to be mindful of how the actions taken up in
event handlers can trigger new events to be fired. You either have to
remove the event handlers at the appropriate time, as you stated, or use
state flags to indicate what events you are currently handling, and prevent
reentrancy.
 
Hi here,
Easy stuff
Have a bool or use the control's tag (if some control events still want to
fire)
--
cheers,
RL
Nicholas Paldino said:
Ray,

No, there isn't. You have to be mindful of how the actions taken up in
event handlers can trigger new events to be fired. You either have to
remove the event handlers at the appropriate time, as you stated, or use
state flags to indicate what events you are currently handling, and
prevent reentrancy.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Ray Mitchell said:
I have a form with a bunch (maybe 30) different controls that generate
events
when changed, clicked, etc. The various event handlers in turn might
change
some of these controls, thereby causing other events, which is not what I
want. So, is there a simple way to turn off all events for a particular
form, then turn them all back on? I know I can individually turn them
off
and on by using -= and += but that seems like a pretty brutal thing to
have
to do. There should be some simple soultion like the equivalent of
"disable
interrupts" and "enable interrupts".

Thanks,
Ray
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top