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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:48:58+00:00 2026-05-23T23:48:58+00:00

What is the best way to close a form and get to another form.

  • 0

What is the best way to close a form and get to another form.

At present I have a Main Form and then two forms:

I want to know how to close one form and open another form efficiently.The two times I did it had a slight different outcome:

The main form in my application is just the introduction which will load some Company Logo and show a progress bar which will then take it to a log-in form, where in I have a log-in button, from where the actual application will open.

I have some questions.In the Main Form I have added this code:

    private void Form1_Load(object sender, EventArgs e)
    {
        int i;

        for (i = 0; i <= 100; i++)
        {
            progressBar.Value = i;
            label1.Text = "Please wait while Refresh loads up...";
        }
    }

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

    private void MainForm_Deactivate(object sender, EventArgs e)
    {
        Form form = new FirstForm();
        form.ShowDialog(this);
    }

1) This works fine, just that the new form that opens up is at the task bar and is not in the center of the screen(as I have set it’s property).How do I fix this?

In the First Form I have added this code:

    private void loginButton_Click(object sender, EventArgs e)
    {
        using( ERPQueries eq = new ERPQueries())
        {
            int? count = eq.CheckEmployee(userTextBox.Text,passwordTextBox.Text);
            if (count == 1)
            {
                //testLabel.Text = "Ok";
                this.Close();
                Form form = new SecondForm();
                form.ShowDialog(this);
            }
            else
            {
                testLabel.Text = "Invalid username or password!";
            }
        }
    }

2) Here the next Form pops up in the center of the screen.I want to know how is it different from the first case, as I have used showDialog() in both the cases?

3) Also in the first case my Main Form Disappears, whereas in the second case the First Form is still visible in the background and disappears only after closing the SecondForm.

I’m sure I’m doing a lot of mistakes, my code is flawed.Please help.This is the first time I’m making an application with multiple forms.

Edit:

When I use Show() instead of ShowDialog() I don’t see the new form.Am I missing something?
I tried this.Dispose() instead of this.Close().In the first case it works fine.In the second case, it disposes all 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-23T23:48:58+00:00Added an answer on May 23, 2026 at 11:48 pm

    try:

    form.Show();
    

    not

    form.ShowDialog(this);
    

    which is what makes it modal.

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

Sidebar

Related Questions

What is the best way to close a form's webpage after the submit button
I have the following code: function submitHandler($link, $modal, close) { var $form = $modal.find('#main-form');
The best way to explain my problem is by a example. I have a
The best way of describing this is I have a table of people with
I'm trying to figure out the best way to manage multiple forms in a
I have a windows form application that will open other forms, but will only
What's the best way to simulate a troolean variable with an HTML form? Specifically,
I have a main form that loads and immediately start receiving data from a
I have a form with a save button, but i want users to be
is there a best way to manage a form in WPF application which has

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.