Problem showing a panel and hiding another

1

I am creating a form and I am using a tabControl , within a tabPage . I am using several panels, my panels cover all the space, therefore, they are on top. I send them to call in this way:

private void salud_Click(object sender, EventArgs e)
{
    Salu.Visible = true;
    Economico.Visible = false;
}

The problem is that when I press the first button its panel appears, but when pressing another button, its respective panel no longer appears.

    
asked by Point Vocational 17.05.2017 в 03:06
source

2 answers

0

It is possible that although it does not look like it, the second Panel is "son" of the first, and therefore when hiding the first the second remains hidden. To fix it, try doing something like this in the constructor of your form:

 public Form4()
 {
     InitializeComponent();
     Salu.Parent = this.tabControl1.TabPages[0];
     Economico.Parent = this.tabControl1.TabPages[0];
 }

Obviously you will have to change this.tabControl1.TabPages[0] depending on the name of your TabControl and the index of TabPage where they are.

    
answered by 17.05.2017 / 12:05
source
0

Assuming the first panel is Salu and the one above is Economico , with a button to show each of them, this should work:

private void BtnVerPanelSalu_Click(object sender, EventArgs e)
{   
   Economico.Hide();
}
private void btnVerEconomico_Click(object sender, EventArgs e)
{
    Economico.Show();
}

... or also:

private void BtnVerPanelSalu_Click(object sender, EventArgs e)
{
    Economico.Visible = false;
}
private void btnVerEconomico_Click(object sender, EventArgs e)
{
    Economico.Visible = true;
}
    
answered by 17.05.2017 в 11:17