Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, March 22, 2011 1:57 PM
Hi,
I have 2 windows forms in my application. I have hide my main windows form after click to open second windows form. But the problem exist when I click on close button on caption bar. Second form was close but my application doesn't exit/close properly. And my main form still hide from visible.
Any possible way to exit my application totally after I clicked on close button on caption bar on my second windows form?
Sorry for my poor English. Thank you.
All replies (3)
Tuesday, March 22, 2011 2:41 PM ✅Answered | 2 votes
Hi,
In Form Closing event of Second Form, write Application.Exit();
Please mark the post as answer if it is helpfull to you - Hiran Repakula
Tuesday, March 22, 2011 3:11 PM ✅Answered
Do you use any threads (Threading namespace)?
If you dont (so only one main thread of the project is opened; before closing it), the application should exit with: this.Close() or this.Dispose() methods (if you write this code in MainForm (form1 by default)), ot with Application.Exit() method.
If you have opened any other thread, which is not yet closed, the application will close (the form1), but will not really exit.
But if you have only two forms opened (with no other threads), you can do as Rihan proposed (Application.Exit() method will do).
Mitja
Tuesday, March 22, 2011 3:22 PM | 1 vote
In the Deactivate event procedure for Form2, put:
Application.Exit();