Link to home
Start Free TrialLog in
Avatar of dominicwong
dominicwong

asked on

How to detect if user has made changes to a windows application in C#

Hi experts
I am developing a C# .NET 3.5 applications using Winform.

I wonder how to detect user has made any changes so that it will prompt the user to save settings before exiting from the application.

Thanks in advance.
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

The idea is that whenever your change, say for example modify text in a textbox, in the respective event a global FLAG could be set. Say for example IsModified = true.
Once user Save/Cancel then the flag should be reset IsModified = false.

If IsModified = true and user tries to close the application, then the user could be prompted.
Avatar of dominicwong
dominicwong

ASKER

Thanks EaswaranP.
But what if my application has hundreds of Controls such as Textbox, Combobox, checkbox, dgv, etc, it would be tedious to add a flag to every event handler.
SOLUTION
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks julianH and EaswaranP.
These links are excellent references!!