I am writing a windows forms application that has a check box regarding the application being added to start up (via registry). If the user checks the box, the CheckedChanged event handler triggers a method that attempts to add the application to the registry. If, for any reason, this fails, I want to revert the check box to its unchecked state, however doing so triggers the method again recursively. How can I avoid this?
Similarly, when the application first loads, I look at the registry and accordingly set the initial state of the checkbox. When I programmatically set the state of the checkbox, the even handler fires, which I do not want.
Is there any way I can suppress the even handler from triggering the CheckedChanged method?
A simple flag would suffice.
And set the flag accordingly.