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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:01:39+00:00 2026-05-14T15:01:39+00:00

I want to close the current form I’m on (MainForm) and then opening a

  • 0

I want to close the current form I’m on (MainForm) and then opening a second one (Form).

I’ve tried:

private void buttonStartQuiz_Click(object sender, EventArgs e)
{
    this.Close();

    Form2 form2 = new Form2();
    form2.ShowDialog();
}

Or adding the this.Close(); after form2.ShowDialog() also doesn’t work.

Any hints?

EDIT: Might as well add that by adding this.Close() after form2.ShowDialog() it close only when I close the new form.
If I choose form2.Show() instead it immediately closes both of the forms.

  • 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-14T15:01:39+00:00Added an answer on May 14, 2026 at 3:01 pm

    Change

    this.Close();
    

    To:

    this.Hide();
    

    Because you can’t Close Main Application window and want to application runs after it.
    You must hide main form or change main window to window who was still opened.

    In this case you must close main window after ShowDialog() was ended.
    Then you must add on the end of this button event function this.Close()

    Your code new code is:

    private void buttonStartQuiz_Click(object sender, EventArgs e)
        {
            // hide main form
            this.Hide();
    
            // show other form
            Form2 form2 = new Form2();
            form2.ShowDialog();
    
            // close application
            this.Close();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my code to close the current form and open another form without
I want to close out my old question start a new one with a
The background: My form has a TWebBrowser. I want to close the form with
I want to capture the browser window/tab close event. I have tried the following
I know that docmd.close will close the current form but for some reason I
In current NSWindowController, add a child window (mainViewController.window),then close current window,BUT when the method
I want to close a running midlet. But the current item on Display is
I have a jdialog and want close it on confirmation after that store the
I want to close the dialog box when you click outside of the dialog,
I have this problem since I'm beginning in OOP programming I want to close

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.