1
votes

I have 3 panels on top of each others and 3 buttons. What I want to achieve is with every button click its correspondent panel appears, currently I am using panel.Visible = true; and panel.Visible = false; but since every element over a panel in a WFA is considered a child of that panel all I get is either they are all visible or they are all invisible.

Q: How to make each panel behave separately?

This is the visibility control code:

private void btnHome_Click(object sender, EventArgs e)
{
    panelHome.Visible = true;
    panelContact.Visible = false;
    panelOther.Visible = false;
}

private void btnContact_Click(object sender, EventArgs e)
{
    panelHome.Visible = false;
    panelContact.Visible = true;
    panelOther.Visible = false;
}

private void btnOther_Click(object sender, EventArgs e)
{
    panelHome.Visible = false;
    panelContact.Visible = false;
    panelOther.Visible = true;
}
1
Can't you use a tabcontrol? - rene
yes sure I can, but in this case panels are needed - Thorvald
To place a panel on top instead of nested inside another panel you can bring it close and then use the keyboard for thas couple of pixels. But of course you can also do it in code.. - TaW

1 Answers

2
votes

This issue is easly solved using the graphical user interface:

You just need to carefully place every panel on top of the previous one until the blue guidelines appear.

PS: You need to check 2 guidelines: one vertical (left or right) and one horizontal (top or bottom)