controls inside panel removed after hiding it

  • Thread starter Thread starter emmeicsics
  • Start date Start date
E

emmeicsics

I don't understand if this behaviuor is by design or I'm missing
something.

I have a form with 2 panels.

Inside panel1 there's a button which, when clicked, hides panel1 and
shows panel2.
Inside panel2 there's another button which, when clicked, hides panel2
and shows panel1.

The code is something like this:

mypanel1button_click(object sender, System.EventArgs e)
{
this.panel2.BringToFront();
}
mypanel2button_click(object sender, System.EventArgs e)
{
this.panel1.BringToFront();
}

I tried using hide() and show() instead of bringToFront() to no avail.

What's wrong with my code?

thank you
maxx
 
this.panel1.controls.clear();

:-(

sorry for the silly question.

maxx

Try setting the Panel's Visible property to false instead.
Also, BringToFront() method only changes the z-order (child control's
order), nothing more.
That's not what you want here.

- Jin
 
Back
Top