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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:59:08+00:00 2026-06-10T22:59:08+00:00

Brief: The code (two functions) explaining all what i am trying to do and

  • 0

Brief: The code (two functions) explaining all what i am trying to do and figures telling my problem

Whenever I have to open a new child Form in my apllication. I use to call the following function. (A child form can have another child)

    public void openNextForm(Form f1, Form f2)
    {
        f2.Owner = f1;                  
        f2.WindowState = FormWindowState.Maximized;
        f2.FormClosing += new FormClosingEventHandler(f_FormClosing);
        f1.Hide();
        f2.ShowDialog();
    }



    // When I close a child form by clicking cross or with ALT-F4
    void f_FormClosing(object sender, FormClosingEventArgs e)
    {
        Form f = sender as Form;
        f.Owner.Show();
    }

On closing child form I use to show the owner/parent form. It is working all right.

But in some cases some controls (Buttons) of owner form are hidden when it is shown on closing child form like

enter image description here

But the actual state of this form wasenter image description here

I have to face this behavior only when I am going back from a complex and lengthy coded child form (still in this case it works fine sometime). Behavior is normal in case of simple (small coded) child forms.

If I press alt key on the weird behaving form, the from is shown surprisingly in the actual state

I have tried to look for this problem and found a lot of similar, but the closest i could see was following and still it is unable to help me at all in case of showdialog

C# Form Problem: new form losing control and randomly hiding

In case of using following code from above link, whenever i open a child form and then again a child form. All forms are hidden. So it is not working as well.

    public void openNextForm(Form f1, Form f2)
    {
        f2.Owner = f1;            
        f2.Show();
        f1.Hide();
        f2.FormClosing += new FormClosingEventHandler(f_FormClosing);
    }

Using tabs should be a solution but i want to keep forms separate and a consistent behavior in all cases during closing/hiding/showing

  • 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-10T22:59:09+00:00Added an answer on June 10, 2026 at 10:59 pm

    Not sure if it will solve the problem, but i see some improvements that can be made which might do the trick.

    Be aware, couldn’t verify if it works.

       

    public void openNextForm(Form f1, Form f2)
        {
            // we don't need ownership since f1 is hidden.                
            // f2.Owner = f1; 
            f2.WindowState = FormWindowState.Maximized;
            // we don't need this event handled since we use ShowDialog
            //f2.FormClosing += new FormClosingEventHandler(f_FormClosing);
            // The following should hide f1 after f2 is displayed even when using dialog
            f2.Shown += (s, e) => {
                f1.Hide();
            };
            f2.ShowDialog();
            f1.Show();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem in brief I have got a piece of working two dimensional scrolling code.
Brief background: I have two-step login page, which after step 1 sends one-time code
All the automated, online converters weren't able to convert this code. Unfortunately my brief
Let me brief you the whole requirement first. I have the following HTML code:
Brief version of my question: This code crashes the compiler. pThread[0] = new boost::thread(
For a brief report I have to do, our class ran code on a
I have two classes: class A { public: /** Brief description * Grand description
In brief: What is the pattern called in the following code, and how should
Brief Context: Hi, I am a university student (behind proxy 10.3.100.211:8080), new to ROR,
Brief Idea about the flow : I have say minimum 1 and maximum 18

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.