0

Warning! This is noob question probably! Sorry in advance.

I'm learning C# (using MS Studio 2013) and I'm having hard time creating some kind of decent navigation in simple desktop program.

Basically what I want is this: MenuStrip with options like "calculate something", "Calculate somethingelse"... and other (that I can easily add later - like dynamic menu on a webpage). If you click first option inside the Form connected with the StripMenu you will get some controls that allows you to do something(like inputs on a webpage). If you click the second all these options will disappear and you will get a fresh set of controls where you can do somethingelse (simply another webpage to play with).

What is the best way to do it (I find it amazing hard to find out :) ). Only way I figured out (more from experience in js then tutorials) is to use show/hide like in javascript/html.

ExamplePanel.Visible = false;
ExampleOtherPanel.Visible = true;

But this doesn't seem right - I think it would be impossible to manage in bigger program (not only in code, but visual designer too - you can only fit that much Panels inside Form).

Any advice? Or at least a link to material where I can find out?

EDIT: Finaly I gave up and used multiple Forms as sugested in answer.

    private void MenuStripExample_Click_1(object sender, EventArgs e)
    {
        SomeForm SomeForm = new SomeForm();
        this.Hide(); //Hide the main form before showing the secondary
        SomeForm.ShowDialog(); //Show secondary form, code execution stop until SomeForm is closed
        //this.Show(); //You may uncomment this if you want to have the previous Form to get back after you close new one
    }
baron_bartek
  • 1,073
  • 2
  • 20
  • 39
  • This is one of the beauties of visual designing. Try it see if it works. If you don't like it delete it and start over. Keep doing this until you get want you want, then start coding the event handlers for the controls. If everything won't fit on one toolstrip use a second one, or go to a menustrip or a combination of the 2. – tinstaafl Dec 12 '13 at 17:25
  • I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Dec 12 '13 at 17:39
  • ok, I will read it. Thx. – baron_bartek Dec 12 '13 at 17:43

1 Answers1

1

You normaly don't hide and show panels with different layouts. This is not a good design.

If you have complete different navigations/control sets, then create a new Form which is responsible for the control set.

If you don't want to use new Forms take a look at the TabControl.

You may also want to take a look at MDI-Container. You can use a Form as a MDI-Container and display various other Forms as child-elements inside of this container.

user1567896
  • 2,398
  • 2
  • 26
  • 43
  • Thx for interest. Tab control is not what I need (yes it's excelent way to create navigation but only small one). I did consider creating multiple forms, but I was hoping to avoid that (when you swith between forms it shows - one closes, another starts). Is there really no other way? – baron_bartek Dec 12 '13 at 17:29
  • What exactly are you trying to do? Of course you can use panels and show and hide them but this is not the way you should do it. It will be 'difficult' to design in the editor with different panels and it is simply not a good design. If you are coming from web-development you should consider that you have different design patterns for desktop programms ;). – user1567896 Dec 12 '13 at 17:32
  • Yes. Hiding/showing panels is not good (blah! Its not possible in any bigger program :) ). And yes I come from webdevelopement :D. Basicly what I want is to have sth similar navigation dropdown meni from website inside desktop program (MenuStrip exen looks so). So far you solution with new Form is the best one (new Form == new page) :P . What do you exacly mean by design patterns? Any links? – baron_bartek Dec 12 '13 at 17:41