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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:43:01+00:00 2026-06-06T23:43:01+00:00

I have main form.I invoke form2 from Mainform using form2.ShowDialog(Application.OpenForms[MainForm]); then i invoke another

  • 0

I have main form.I invoke form2 from Mainform using form2.ShowDialog(Application.OpenForms["MainForm"]);
then i invoke another form from form2

    this.Hide();
    form3.ShowDialog(Application.OpenForms["MainForm"]);
    this.Dispose();

Everything works fine but when a form3 is displayed i get a glimpse of any window displayed in the background ie:If i had opened MS paint put it in the background the Paint window will come on top of my window for time less than a second and automatically go to the backgroud.
Why is this behavior.How can i correct it?

  • 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-06T23:43:03+00:00Added an answer on June 6, 2026 at 11:43 pm

    When you call this.Hide(), Form2 is hidden and another window needs to get focused. However, you opened Form2 with ShowDialog, which means Form2 is the only window that can get focused in your application. But since you hid Form2, Windows finds another window to focus (in this case MS Paint).

    One suggestion for a solution could be to artificially give MainForm focus before hiding Form2:

    Application.OpenForms["MainForm"].Activate();
    this.Hide();
    form3.ShowDialog(Application.OpenForms["MainForm"]);
    this.Dispose();
    

    Perhaps a more beautiful solution would be to first open Form3, wait for it to be shown, and then hide Form2. To do this, put this code in Form2, when you want to show Form3:

    form3.Shown += (_s, _e) => Application.OpenForms["Form2"].Hide();
    form3.ShowDialog(Application.OpenForms["MainForm"]);
    this.Dispose();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Main form.I want to launch another form from it and launch
I have a form MainForm with several properties/methods that are accessed from another thread.
Events are synchronous in C#. I have this application where my main form starts
I have WPF Application where I have One main form and other user controls
In my current application I have a main form: frmMain with a statusstrip and
I have a winforms application that doesn't really have a main form - it's
I have a main form that is launched and then it can go to
I have an application that start System.Threading.Timer, then this timer every 5 seconds read
I have a main Form. There is a linklabel. If i click on it,
I have a main form, and a floating child form that is non-modal. The

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.