dkDeveloper
asked on
Saving Dirty Forms on Windows App Close (C# .Net 2.0)
Experts,
I need some general advice on Windows form application development. We're writting a module for Microsoft's CAB framework. Our main content for this module is a DockPanel, ultimately containing multiple forms displayed as tabs.
What I'd like to be able to do is check each tab when the application is quit to see if the form is dirty, and if so, prompt the user to save his/her changes. I've done this sucessfully for each close of the tab, but I'm not sure what the cleanest solution is to implement this on the application closing.
I can add an event listener to the onClosing event of the Shell Application, but that seems a bit dirty. I don't know that I'm properly using the validation provided by windows, it seems like all forms should validate when they are unloading.
Any advice?
Thanks in advance,
dK
I need some general advice on Windows form application development. We're writting a module for Microsoft's CAB framework. Our main content for this module is a DockPanel, ultimately containing multiple forms displayed as tabs.
What I'd like to be able to do is check each tab when the application is quit to see if the form is dirty, and if so, prompt the user to save his/her changes. I've done this sucessfully for each close of the tab, but I'm not sure what the cleanest solution is to implement this on the application closing.
I can add an event listener to the onClosing event of the Shell Application, but that seems a bit dirty. I don't know that I'm properly using the validation provided by windows, it seems like all forms should validate when they are unloading.
Any advice?
Thanks in advance,
dK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What about in destructor of a from. Can you have those form as your own class derived from current form class?
ASKER
I ended up creating an interface that basically contains a method to determine if the form is dirty, a method to prompt saving, and a method to actually save the form. Then when the main shell.application form is closing I loop through all open tabs and utilize that interface to force those windows to potentially save themselves.
This really shouldn't have been this difficult and I think I just ran into so many problems with it due to the fact that we were using both the CAB and other third party controls. At any rate, thanks to everyone for trying to help. I'm going to go ahead and (partially) accept WebStorms answer since that is generally what you would do.
Thanks again guys!
dK
This really shouldn't have been this difficult and I think I just ran into so many problems with it due to the fact that we were using both the CAB and other third party controls. At any rate, thanks to everyone for trying to help. I'm going to go ahead and (partially) accept WebStorms answer since that is generally what you would do.
Thanks again guys!
dK
ASKER
At any rate - no luck with that.
Any other thoughts or suggestions?
Thanks,
dK