المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : mark as unsaved if the user changes ANYTHING?



C# Programming
07-25-2009, 11:19 PM
I'm writing an app where you can input a lot of data in a lot of different controls (textboxes, updowns, etc.)

Now I want to implement a function you see in most other apps where you input information and save it: the moment the user changes a saved file or inputs something into a new file, the file is unsaved and upon closing it, the user will be prompted if he wants to save changes.

The only way I can think of to achieve this is to use each input control's change event (change text for textbox, change value for UpDown, etc.) and set an "unsaved" bool to true.
When the user wants to exit the app, check the bool and display a message box if necessary.

Is there an easier way other than using all the events (I have a lot of data, so that would be about half the code of each form or more)?