controls inside panel removed after hiding it

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
 
J

Jin Chang

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top