Home > OS >  How do I close the whole application when I close a form?
How do I close the whole application when I close a form?

Time:05-15

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.

CodePudding user response:

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();
    }
  • Related