David Santos
David Santos

Reputation: 13

How do I close the whole application when I close a form?

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.

Upvotes: 1

Views: 73

Answers (1)

thisisnabi
thisisnabi

Reputation: 1200

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

Upvotes: 1

Related Questions