Reputation: 87
I have a login windows form that pops up when I open MS Access. If the user decides to leave, I have a cancel button that closes the application and MS Access:
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
But I also want to add that if the user terminates the windows form, it will also terminate MS Access.
ie., if windowForm terminated, then Application.Exit
Upvotes: 3
Views: 1090
Reputation: 1893
Add a function to the FormClosing
event in the Event Properties of your Form or manually:
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
And then write:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
Upvotes: 1