is there a easyway to disable Event handler during startup.....  
Author Message
Barbfrog





PostPosted: Visual C++ General, is there a easyway to disable Event handler during startup..... Top

Hi! All
I'm starting to get into C++/CLI managed now that I'm getting used to to Syntax...
Anyway This is my story...............
C++/CLI seems to have the same issue that VB has in that when you start the program and load your saved options into the checkboxs/radiobuttons the event handlers CheckChanged fire,,,,,, I don't need these firing cause I am just loading them up with the saved options from the registry keys.....Nothing needs to be changed ... Is there a easy way to disable them on program startup.
The way I got around that In VB is to add a startup flag.. . Skip if true..........
Thanks............


Visual C++7  
 
 
Alex Farber





PostPosted: Visual C++ General, is there a easyway to disable Event handler during startup..... Top

There is no difference in handling events between VC, C# and C++/CLI, except of syntax.

Generally, every event handler can be canceled by using -+ operator. For example, this line adds event handler:

button1.Click += new EventHandler(this.button1_Click);

This line removes event handler:

button1.Click -= new EventHandler(this.button1_Click);

However, removing all event handlers on startup and adding them again looks like hard way, startup flag is better solution.