Groups | Blog | Home
all groups > visual c > april 2004 >

visual c : Is there a way to temporarily disable events?


mccoyn
4/29/2004 6:06:04 AM
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)
mccoyn
4/29/2004 1:31:02 PM
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

David Lowndes
4/29/2004 5:36:18 PM
[quoted text, click to view]

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.

AddThis Social Bookmark Button