I have two forms in my application, Login and Dashboard. After the login the dashboard form is loaded and login "closes" with this.Hide
. If I close the dashboard with the X button the application continues to run but nothing shows.
Asked
Active
Viewed 51 times
1

David Santos
- 13
- 2
-
1this.close instead of this.hide? – urlreader May 07 '22 at 19:39
-
When `Dashboard` closes, also close `Login`, so the app exists. Or, make `Dashboard` the starting Form, so when it closes the app also closes. Or do [something like this](https://stackoverflow.com/q/10769193/7444103). Or handle a custom ApplicationContext. – Jimi May 07 '22 at 19:57
1 Answers
1
Use Form2 [Dashboard] events.
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
// when form closed
Application.Exit();
}
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
// before form close
Application.Exit();
}

thisisnabi
- 1,045
- 9
- 21