How do I close application when form 1 is hidden, and all other forms are closed?
I've currently got it set to, after I click a button on form 1, it opens form 2, and hides form 1; At which point you can move to forms 3, 4, etc. I want to be able to, once I close the last open form, all others being hidden, to close the whole application as well.
I'm pretty new to c#, so feel free to dumb it down for me.
Asked
Active
Viewed 262 times
-1

DA1412
- 1
- 1
-
2Environment.Exit() is the dumbed-down way. It doesn't take that much effort to do it [the correct way](http://stackoverflow.com/a/10769349/17034) so you don't have the hide a window anymore. – Hans Passant Mar 27 '16 at 22:38
-
@HansPassant I tried the "Correct way" as you put it, and all that did was set to close the application if there were no open forms. not if there were not VISIBLE forms, which is what I'm looking for. Any suggestions as to how best to do that? – DA1412 Mar 28 '16 at 21:59
1 Answers
0
Use
Application.Exit();
to end the program and close all forms.

Ashkan Mobayen Khiabani
- 33,575
- 33
- 102
- 171