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

  • Home
  • SEARCH
  • 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 4238258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:52:53+00:00 2026-05-21T02:52:53+00:00

I want to be able to show, hide or close some other forms within

  • 0

I want to be able to show, hide or close some other forms within one form. the idea is my program starts with one form and there are some buttons that will show other forms. That is if user clicks on a button for bringing on another form, this main form should minimize and whenever user close the other form this form will be back to normal or maximized state.

The code looks like this for my main form that controls other forms (Form1.cs):

namespace MultipleForms
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    /* 
     * I want to make a public reference to this Form1
     * So that when user closes Form2 That is F2 this form will be
     * set back to normal or maximized state
     */ 

    private void buttonStartForm2_Click(object sender, EventArgs e)
    {
        //Declare Form2
        Form2 F2 = new Form2();

        //Show Form2
        F2.Show();

        //Minimize Form1
        this.WindowState = FormWindowState.Minimized;

    }
}
}

And this is Form2.cs

    namespace MultipleForms
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        //FormClosed event handler
        private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            //Closing Form2
            this.Close();

            //Now I need a code to make Form1 to recover from minimized
            // state to normal or maximized state. how do I should refer to it?
        }
    }
}

I think I have to do some stuff on form closing event, but how can I initilize the Form1.cs as something public? or I also should initilize Form1.cs in Form2.cs also? or maybe it should be done through Program.cs file:

namespace MultipleForms
{
static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}
}

P.S: it is crtitical that Form2 should be closed, not hided

UPDATE

Using Hans solution, it is the best to use it this way:

    private bool isEnabledCmpFrm = false;

    public void buttonStartComparisonForm_Click(object sender, EventArgs e)
    {

        if (!isEnabledCmpFrm)
        {
            ComparisonForm CmpFrm = new ComparisonForm();
            CmpFrm.Show();
            CmpFrm.WindowState = FormWindowState.Normal;
            this.WindowState = FormWindowState.Minimized;

            isEnabledCmpFrm = true;

            CmpFrm.FormClosed += delegate
            {
                this.WindowState = FormWindowState.Normal;
                isEnabledCmpFrm = false;
            }; 
        }
    }
  • 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-21T02:52:53+00:00Added an answer on May 21, 2026 at 2:52 am

    Don’t have a form listen to its own events. The code needs to go in Form1. Like this:

            Form2 F2 = new Form2();
            F2.FormClosed += delegate { this.WindowState = FormWindowState.Normal; };
            F2.Show();
            this.WindowState = FormWindowState.Minimized;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to play sound files in my program. Where should
I want to be able to make an HTTP call updating some select boxes
I have a Windows application that has 2 Forms . From one form I
I want to show and hide a label and its control. I can do
I want to be able to capture the exception that is thrown when a
I want to be able to do: For Each thing In things End For
I want to be able to view a SQL Server 2005 Reporting Services report
I want to be able to do this. MyInterface interface = new ServiceProxyHelper<ProxyType>(); Here's
I want to be able to generate PDF output from my (native) C++ Windows
I want to be able to get an estimate of how much code &

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.