Is there a way to temporarily disable events?

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

Guest

I would like to be able to change a property of a control without calling the event handler I have registered for it. For example, I would like a function like the following

void SilentSet(CheckBox* checkbox, bool set)
DisableCheckedChangedEvent(checkbox)
checkbox->Checked = set
EnableCheckedChangedEvent(checkbox)
}
 
I would like to be able to change a property of a control without calling the event handler I have registered for it.

You could tackle the problem the other way around. Set a flag, change
the property. In the handler, if the flag is set, don't do the
operation, but clear the flag.

Dave
 
Thats what I'm doing for now, but I think things would get a little messy if I have to create a new variable for every event I have. I would like a general way to do it that doesn't require such restructuring

I'm porting some old Unix code to .Net Windows Forms. The function I am trying to replace has an argument called notify that can be set to false to avoid the event handlers. It would be so much easier on me if I had some general purpose way of doing this instead of rewriting every single function call
 
Back
Top