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 4028290
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:12:09+00:00 2026-05-20T11:12:09+00:00

im developing windows application using c#. i want to close the application and show

  • 0

im developing windows application using c#. i want to close the application and show new form after clicking the button, i did it, but every time i cliecked the button, it shows the another windows and when i going to task manager that form isntance still running. i want avoid that. i am using this.close() function to exit from the form.

  • 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-05-20T11:12:09+00:00Added an answer on May 20, 2026 at 11:12 am

    Let’s suppose you have Form1 and Form2.

    The code in Form1 should be something like this:

    public partial class Form1 : Form
    {
        private Form2 _form2;
    
        public Form1()
        {
            InitializeComponent();
            _form2 = new Form2();
            _form2.VisibleChanged += new EventHandler(_form2_VisibleChanged);
        }
    
        void _form2_VisibleChanged(object sender, EventArgs e)
        {
            if (!_form2.Visible)
                Show();
        }
    
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
            _form2.Show();
        }
    }
    

    And in Form2 all you need to do is:

    private void Form2_FormClosing(object sender, FormClosingEventArgs e)
    {
        e.Cancel = true;
        Hide();
    }
    

    Of course, you must suscribe to the event FormClosing in Form2, but if you do it through the designer (Form Properties, clicking on Events icon) just paste those two lines inside the method it creates)

    What is this code doing?

    In Form1:

    • Create a instance of Form2
    • In Form1_FormClosing method, all we do is hide the form instead of closing it when the user closes it, and showing the instance of Form2
    • Suscribe to the VisibleChanged event
    • When the event fires, if the instance of Form2 isn’t visible, then Form1 appears.

    In Form2:

    • The 2nd of the above steps, but without showing anything.

    If you want to do it when you click on a button, all you need to do is do the same but on the Click event on the button instead of the FormClosing event.

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

Sidebar

Related Questions

I am Developing Windows Form Application in .Net, I want to insert selected rows
I've got two applications I'm developing using Qt on windows. I want the user
I am developing an application using Windows Mobile 5.0, under embedded VC++ 4.0, and
I developing ASP.NET application using a Swedish version of Windows XP and Visual studio
I'm developing an application for Windows Mobile Devices using Visual Studio .NET 2008 whose
I have been developing a C# windows form application in XP. It all works
Im developing a simple console application using java. I want to display currently running
We are developing a Windows application using C#. We would like to change the
We're developing a large desktop application using Windows Presentation Foundation. Currently, the application is
I am developing a Windows .NET application (WinForms) and I need to simulate a

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.