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

x
?
Solved

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

Posted on 2012-09-02
5
Medium Priority
?
2,731 Views
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.
0
Comment
Question by:dominicwong
  • 2
  • 2
5 Comments
 
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.
0
 

Author Comment

by:dominicwong
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.
0
 
LVL 16

Assisted Solution

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

http://shtproject.blogspot.in/2012/08/c-windows-application-for-sht11_23.html
http://ashishkhandelwal.arkutil.com/system-analysis-and-design/observer-pattern/
http://www.barebonescoder.com/2010/11/observer-pattern-with-c-inotifypropertychanged/

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.
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 1200 total points
ID: 38360082
0
 

Author Closing Comment

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

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