OK - you have three panels which presumably occupy the same screen "real estate".
So you can only display one of them at a time.
So when you want to show a panel, you set it's
Visible
property to
true
- but that's not enough to make sure it can be seen, because one of the other two could be in the same place, and could cover it - so you have to ensure that the "competition" is hidden by setting their
Visible
property to
false
:
Which means that your three buttons need to look like this:
private void mostActive_Click(object sender, EventArgs e)
{
activePan.Visible = true;
gainpan.Visible = false;
losPan.Visible = false;
}
private void mostGainers_Click(object sender, EventArgs e)
{
activePan.Visible = false;
gainpan.Visible = true;
losPan.Visible = false;
}
private void mostLosers_Click(object sender, EventArgs e)
{
activePan.Visible = false;
gainpan.Visible = false;
losPan.Visible = true;
}
If you don't explicitly hide what you don't want to see, it will likely stay there and cover what you do want to see!
Does that make sense?
"What is a good "second option" to the "z-order" what would I want to use to display other panels?"
Don't worry about z-order for the moment - you probably don't need to play with it at the moment.
Instead, write a method which turns all your panels off, and displays one of them:
private Panel ShowOnly(Panel showThis)
{
activePan.Visible = false;
gainpan.Visible = false;
losPan.Visible = false;
if (showThis != null)
{
showThis.Visible = true;
}
return showThis;
}
You then call it each time, passing the name of the Panel you want visible and it does the rest.
private void mostActive_Click(object sender, EventArgs e)
{
ShowOnly(activePan);
}
private void mostGainers_Click(object sender, EventArgs e)
{
ShowOnly(gainpan);
}
private void mostLosers_Click(object sender, EventArgs e)
{
ShowOnly(losPan);
}
And your "Hide them all" feature is equally simple:
private void sideDashboard_Click(object sender, EventArgs e)
{
ShowOnly(null);
}
That way, adding a new Panel just means adding the
Visible=false
line to ShowOnly, and calling it with the new panel when you want it visible.