Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close entire application when application has more than 2 forms without showing messagebox more than once
    text
    copied!<p>I am developing a application using windows forms. The project contains 3 forms: one login form which is the main form and two others which are child forms to the login form.</p> <p>My problem is when want to close the total application by using <code>Application.Exit()</code> in form closing event my messagebox showing the dialog more than once. </p> <p>1.This code in Login form i.e main form:</p> <pre><code>private void FrmLogIn_FormClosing(object sender, FormClosingEventArgs e) { DialogResult loginResult = MessageBox.Show("Do you want to close this application?","Close",MessageBoxButtons.YesNo,MessageBoxIcon.Warning); if (loginResult == DialogResult.Yes) { Application.Exit(); } } </code></pre> <p>2.AdminForm closing event which is child form to login form:</p> <pre><code> private void FrmAdmin_FormClosing(object sender, FormClosingEventArgs e) { DialogResult loginResult = MessageBox.Show("Do you want to close this application?","Close",MessageBoxButtons.YesNo,MessageBoxIcon.Warning); if (loginResult == DialogResult.Yes) { Application.Exit(); } } </code></pre> <p>3.Billoperations form closing event which is child form to login form:</p> <pre><code>private void FrmBillOperation_FormClosing(object sender, FormClosingEventArgs e) { DialogResult loginResult = MessageBox.Show("Do you want to close this application?","Close",MessageBoxButtons.YesNo,MessageBoxIcon.Warning); if (loginResult == DialogResult.Yes) { Application.Exit(); } } </code></pre> <p>When i click the close button in any form it will show MessageBox message only once. Please help me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload