[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2012-09-02
Medium Priority
Last Modified: 2012-09-03
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.
Question by:dominicwong
  • 2
  • 2
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 38359962
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.

Author Comment

ID: 38359973
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.
LVL 16

Assisted Solution

by:Easwaran Paramasivam
Easwaran Paramasivam earned 800 total points
ID: 38360004
If more controls then you could Implement Observer pattern.


Please do refer above links. They could help you. Observer pattern in nothing but when event triggers it notifies others.

Please google on the topic more to implement the same.

This is the way you have to go.
LVL 60

Accepted Solution

Julian Hansen earned 1200 total points
ID: 38360082

Author Closing Comment

ID: 38362266
Thanks julianH and EaswaranP.
These links are excellent references!!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
Viewers will learn the different options available in the Backstage view in Excel 2013.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question