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

The Archive Base Latest Questions

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

I was looking something similar with winforms like // in Form 1 this.Hide(); Form2

  • 0

I was looking something similar with winforms like

// in Form 1
this.Hide();    
Form2 form = new Form2();
form.Show


// in Form 2
// if button pressed, Form 1 will be displayed, while Form 2 will be Hide.

I was trying my luck for FormEventHandler but doesn’t know where to start.

Any suggestions/ideas?

  • 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-14T08:40:00+00:00Added an answer on May 14, 2026 at 8:40 am

    (For the purposes of this answer, Form1 and Form2 represent classes inheriting from Windows.Window)

    I would recommend one of the following approaches

    Approach 1: Keeping Form2 alive and able to show again

    In this case, you’ll need to make an instance variable on Form1:

    private Form2 form2;
    

    In your code to “switch” to Form2, do this:

    if(form2 == null)
    {
        form2 = new Form2();
    
        DependencyPropertyDescriptor.FromProperty(Window.VisibilityProperty, 
                typeof(Window)).AddValueChanged(form2, Form2_VisibilityChanged);
    }
    
    Hide();
    
    form2.Show();
    

    Then add this function to Form1:

    private void Form2_VisiblityChanged(object sender, EventArgs e)
    {
        if(form2.Visility == Visibility.Hidden) Show();
    }
    

    Now all you need to do is call Hide(); within Form2 to have it switch back to Form1.

    Approach 2: Closing Form2 and opening a new instance each time

    This is a bit easier, and more in line with what you have:

    Form2 form2 = new Form2();
    
    form2.Closed += Form2_Closed;
    
    Hide();
    
    form2.Show();
    

    Similarly, add this function to Form1:

    private void Form2_Closed(object sender, EventArgs e)
    {
        Show();
    }
    

    Now, instead of calling Hide(); in Form2, call Close();

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

Sidebar

Related Questions

I'm looking for something similar to how Visual Studio will show tooltips when hovering
I'm looking for something similar to the table creation form from phpmyadmin, but it
I'm looking for something similar to this: Active navigation with jQuery - can't apply
I'm looking for something similar in form to weighted.mean() . I've found some solutions
I was looking something similar to this http://roshanbh.com.np/examples/exapandable-panel/ for my android application, ie I
I'm looking for something similar to waitForElementPresent to check whether element is displayed before
I'm looking for something like IEntitesFactory or something similar that allows me to handle
I am looking for something similar to the Ant sql task but that will
I am basically looking for something similar but simpler tool like cURL that fetches
Looking for something similar to xerces for parsing an xml file in ruby. I

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.