-1

I'm supposed to create a small game menu in C#. What i'm doing now is that with each button you click in the main menu, you get a new form so it's something like this.

User clicks: Play

Form playMenu = new Form(); 
playMenu.Show();
this.Hide();

New form including buttons appears with new options to choose from.

I feel like there is a better way to do this but i have no idea how. Something in a way of having just 1 form instead of multiple and having buttons something like this:

User clicks: Options

playButton.visible = false;
options.Visible = true;

Doing the above makes it possible to just have 1 form but wouldn't it be difficult to make changes to the buttons? I have no idea if this is the right way to do this.

Cine
  • 4,255
  • 26
  • 46
A1RStack
  • 75
  • 1
  • 6
  • Maybe a [wizard](http://stackoverflow.com/questions/4954037/which-wizard-control-can-i-use-in-a-winforms-application) is what you looking for? – ckruczek Oct 05 '16 at 09:03
  • @ckruczek It seems to me that a wizard would be more suitable for setups. I can see it's application for something like this but i'm not sure if this is what i'm looking for. – A1RStack Oct 05 '16 at 09:11
  • put tabsheets on your form and the nextbutton click will hide the current tabpage and show the next tabpage – GuidoG Oct 05 '16 at 09:13

1 Answers1

0

You have to design your sub-menus as UserControls instead of Forms, put them all in a single container (Panel) with Dock = DockStyle.Fill and toggle their Visible or z-order (with BringToFront and SendToBack methods).

This gives you much flexibility in terms of visual layout and data flow.

slawekwin
  • 6,270
  • 1
  • 44
  • 57