Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8653519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:33:51+00:00 2026-06-12T14:33:51+00:00

I am developing a application using windows forms. The project contains 3 forms: one

  • 0

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.

My problem is when want to close the total application by using Application.Exit() in form closing event my messagebox showing the dialog more than once.

1.This code in Login form i.e main form:

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

2.AdminForm closing event which is child form to login form:

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

3.Billoperations form closing event which is child form to login form:

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

When i click the close button in any form it will show MessageBox message only once. Please help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:33:53+00:00Added an answer on June 12, 2026 at 2:33 pm

    Make all FormClosing methods call a ApplicationShutdown function which handles this in a central place. You don’t want to copy this code to every new form you create.

    In this method you can check a boolean (watch for thread-safety) called for example IsShuttingDown. If it’s already true, leave the method, otherwise you ask the question and start exiting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing C# .NET windows Forms application. In which I've a main window and
I am developing Windows Form Application using Microsoft Visual C# 2010 I have two
I'm developing a Windows application in VS2005 using C#. In my project, I generate
We are developing a .NET 3.5 application (Windows Forms), which is comprised of 3
We are developing C#.Net 4.0 Windows form based application using Microsoft.Office.Interop.Word reference. Now I
VB Windows form Application.. I am developing an application of which part of the
I am developing an Windows Forms application using VB.NET that offers the user to
I am currently developing an application in C# using Windows Forms. I am using
Im developing a windows forms application using C# 4.0 and that application is going
We developing an Application using .NET Framework 4.0 (C#) windows forms based application. Now,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.