How to detect changes in any control of the form?

后端 未结 3 2593

How can I detect changes in any control of the form in C#?

As I have many controls on one form and i need to disable a button if any of the control value in the form ch

3条回答
  •  被撕碎了的回忆
    2021-02-20 18:18

    Instead of accessing the controls directly you can databind to a model object that implements INotifyPropertyChanged.

    Whenever the user does something that causes the data in your model to change you will be notified and can take the appropriate action.

    It will probably also cut down on the amount of code you need to get values in and out of the form controls.

提交回复
热议问题