I'm currently developing an application with branches in both Web AND WinForms. The application started as a Web App, and now is currently being migrated to WinForms.
One problem I've encountered NUMEROUS times now, is that when building a webform, the change events don't fire during the initialization and setup of the controls, but in WinForms, if i've attached to a change event of some control, when I am building the form programaticly during setup and setting values on things(dropdowns, checkboxs), these events fire. (this is undesired)
The counter measure I've applied so far is to have a class level variable named something like _changeMadeFromCode then whenever I want to set the value of a control, I have to set var to true, set the value on the control, the set the var back to false. Then inside of the event handler, I have to check for the bool and only perform that actions if the var is false.
This works obviously, but it becomes tedious and slightly annoying to implement.
I realize that this is by design in the dotNet framework, I was working if anyone else has come up with a more elegant solution?
One problem I've encountered NUMEROUS times now, is that when building a webform, the change events don't fire during the initialization and setup of the controls, but in WinForms, if i've attached to a change event of some control, when I am building the form programaticly during setup and setting values on things(dropdowns, checkboxs), these events fire. (this is undesired)
The counter measure I've applied so far is to have a class level variable named something like _changeMadeFromCode then whenever I want to set the value of a control, I have to set var to true, set the value on the control, the set the var back to false. Then inside of the event handler, I have to check for the bool and only perform that actions if the var is false.
This works obviously, but it becomes tedious and slightly annoying to implement.
I realize that this is by design in the dotNet framework, I was working if anyone else has come up with a more elegant solution?