0

I'm creating a program where there is one form and there are 6 panels. I just want to show the 6 panels in one form. It's like They are top of each other.

When I click the first button, the first panel will show. when I click the second button, the second panel will show and the first panel will hide. so on and so forth.

I use the

panel1.Visible = true/False; Method.

but when i Clicked the second button, the panel2 are not shown in the form. thank you in advance!

Ian
  • 30,182
  • 19
  • 69
  • 107
  • 1
    Show us some code so we can help you solve your problem. – Seano666 Mar 03 '16 at 06:08
  • This smells [very familiar](http://stackoverflow.com/questions/35741177/hide-show-windows-forms-panel-in-c-sharp). – Ian Mar 03 '16 at 06:14
  • 1
    Use View > (Other Windows) > Document Outline. And you can now see that panel2 is *inside* panel1. So if you hide panel1 then panel2 can never be visible. Fix it by dragging the panel to the form and (carefully) editing its Location property. There are [better ways to do this](http://stackoverflow.com/a/2798241/17034). – Hans Passant Mar 03 '16 at 08:59
  • Adding to Hans' adivice to edit the __location__ values: You can also use the __keyboard__ to place the controls on top of each other. Just __don't use the mouse__, as it will always try to __nest controls inside__ others, whenever these are containers like panels.. And of course there are nice __tool buttons__ in the layout toolstrip to __align__ them top and left and make their size the same, all without any nesting! And sometimes I use [this trick](http://stackoverflow.com/questions/31498890/switch-between-panels/31501261?s=2|0.1183#31501261) to make work in the designer easier.. – TaW Mar 03 '16 at 12:33

2 Answers2

0

have a activePanel variable which refers to the panel that is active. whenever a button is clicked make the activePanel.visible= false.

then set appropriate panel to activePanel.

venkat
  • 269
  • 1
  • 11
0
panel1.BringToFront(); 

this will get the panel1 on top of all the other panels.

vivek verma
  • 1,716
  • 1
  • 17
  • 26