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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:40:02+00:00 2026-05-15T09:40:02+00:00

How do i show a from that have been hidden using this.Hide(); I have

  • 0

How do i show a from that have been hidden using

this.Hide();

I have tried

MainMenuForm.Show();

and this just says i need an object ref. I then tried:

MainMenuForm frmMainMenu = new MainMenuForm();
frmMainMenu.Show();

Which seems to show the appropriate form. But when you exit the app, it is still held in memory because it hasn’t shown the form that was hidden, instead it has shown a new version of the form. In effect having 2 instances of the form (one hidden, one visible).

Just to clarify, the MainMenuForm is the startup form. When (for example) Option 1 is clicked, the MainMenuForm then hides itself while opening up the Option 1 form. What i would like to know is how to i make the Option 1 form that the MainMenuForm opens “unhide” the MainMenuForm and then close itself.

What’s the correct procedure here?

Thanks in advance.

  • 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-15T09:40:03+00:00Added an answer on May 15, 2026 at 9:40 am

    When you do the following:

    MainMenuForm frmMainMenu = new MainMenuForm();
    frmMainMenu.Show();
    

    You are creating and showing a new instance of the MainMenuForm.

    In order to show and hide an instance of the MainMenuForm you’ll need to hold a reference to it. I.e. when I do compact framework apps, I have a static classes using the singleton pattern to ensure I only ever have one instance of a form at run time:

    public class FormProvider
    {
       public static MainMenuForm MainMenu
       {
           get
           {
              if (_mainMenu == null)
              {
                _mainMenu = new MainMenuForm();
              }
              return _mainMenu;
           }
       }
       private static MainMenuForm _mainMenu;
    }
    

    Now you can just use FormProvider.MainMenu.Show() to show the form and FormProvider.MainMenu.Hide() to hide the form.

    The Singleton Pattern (thanks to Lazarus for the link) is a good way of managing forms in WinForms applications because it means you only create the form instance once. The first time the form is accessed through its respective property, the form is instantiated and stored in a private variable.

    For example, the first time you use FormProvider.MainMenu, the private variable _mainMenu is instantiated. Any subsequent times you call FormProvider.MainMenu, _mainMenu is returned straight away without being instantiated again.

    However, you don’t have to store all your form classes in a static instance. You can just have the form as a property on the form that’s controlling the MainMenu.

    public partial class YourMainForm : Form
    {
       private MainMenuForm _mainMenu = new MainMenuForm();
    
       protected void ShowForm()
       {
          _mainMenu.Show();
       }
    
       protected void HideForm()
       {
          _mainMenu.Hide();
       }
    }
    

    UPDATE:

    Just read that MainMenuForm is your startup form. Implement a class similar to my singleton example above, and then change your code to the following in the Program.cs file of your application:

    Application.Run(FormProvider.MainMenu);
    

    You can then access the MainMenuForm from anywhere in your application through the FormProvider class.

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

Sidebar

Related Questions

I'm using a UITableView to show some data from an array. This array can
I have a form element, that is hidden or show depending on a dropdown
I´m working on a project that basically will show some data collected from hardware
I want to write a page that will show all the records from a
Bascially I want to know the best way to hide/show an ASP.NET control from
I have a question concerning using the toggle function. I have a template that
Basically I have a set of checkboxes that are dynamically created from view data
I have been tasked to look after an ASP.Net WebForms application that communicates with
I have been looking into this for hours and still at a loss. I
I have two tables. One is a table of the reports that have been

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.