J
Jules Winfield
My WinForms application can have any number of top level forms open at a given time. If the user selects File|Exit, all of the forms are closed. The loop to close the forms looks something like this:
foreach(MyForm form in AllMyForms){
form.Close();
}
Application.Exit();
The OnClosing method [aka OnFormClosing in .NET 2.0] is overridden in MyForm. If the user has made changes to his form, this method asks him if he'd like to:
a) save his changes
b) forget changes and proceed to close the form
c) cancel the form closure loop and keep working on the form
In the event that the user chooses (c), OnClosing will cancel the closure operation. What I don't understand is why Form.Close() returns void. It seems like it should return a bool indicating whether or not the Close() operation was completed. Am I missing something? Given a call to Form.Close(), how can I tell if the form closure actually succeeded.
The only idea I can come up with is to check the Form.IsDisposed property immediately following the Close() call, with the assumption that if my modeless Form truly did close, it should also be Disposed. Is this the recommended approach?
Jules
In the
foreach(MyForm form in AllMyForms){
form.Close();
}
Application.Exit();
The OnClosing method [aka OnFormClosing in .NET 2.0] is overridden in MyForm. If the user has made changes to his form, this method asks him if he'd like to:
a) save his changes
b) forget changes and proceed to close the form
c) cancel the form closure loop and keep working on the form
In the event that the user chooses (c), OnClosing will cancel the closure operation. What I don't understand is why Form.Close() returns void. It seems like it should return a bool indicating whether or not the Close() operation was completed. Am I missing something? Given a call to Form.Close(), how can I tell if the form closure actually succeeded.
The only idea I can come up with is to check the Form.IsDisposed property immediately following the Close() call, with the assumption that if my modeless Form truly did close, it should also be Disposed. Is this the recommended approach?
Jules
In the