Q
Problem solve Get help with specific problems with your technologies, process and projects.

Moving from one form to another in a menu application

I am trying to make a menu application where I will have roughly 40 forms. From any one of these forms I want to be able to move to any one of six other forms. In VB 6.0, all that was required was to say:

frmMainMenu.hide
frm Appetizers.show

This does not seen to work in .NET though. The only solution that I have seen was to place the forms into an array, which would make the random movement between forms difficult.
Your application will have a main form. That is unavoidable, and you will never be able to close it without shutting down the application. For the child forms, you can simply create and show them and close later. For example, the main form opened a child Form1. At a button's click, this form closes itself and opens Form2:

private void OnForm1ToForm2(object sender, EventArgs e)
{
 this.Close();
 new Form2().Show();
}

This was last published in October 2003

Dig Deeper on C# programming language

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

SearchCloudApplications

Close