How to prevent value changed events from firing on form initialization in .NET?

后端 未结 10 2423
清歌不尽
清歌不尽 2020-12-03 07:01

Consider a simple .NET form with a couple of radio buttons and a checkbox.

Each of the radio buttons has a CheckedChanged handler setup that performs some action bas

10条回答
  •  时光取名叫无心
    2020-12-03 07:48

    "I also can put a boolean field that's not set to true until the form is fully loaded and not process the events if that is false, but it's a dirty hack."

    It's also the easist and best way to do it!

    Lets say .NET provides a neat way to turn an and off all the event handlers until the form is loaded. Even just the ones YOU are handling. It would still not be sufficiently flexible to disable what you wanted to enable but disable what you didn't. Often form setups happen and you want the events to fire. Also the form won't build right if no events fire.

提交回复
热议问题