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
 

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