In a form I have a SplitContainer: in the left panel I have a series of buttons and in the right several panels COUPLED to the right panel of the SplitContainer.
The idea is: by pressing the different buttons on the left panel, the different panels on the right are shown (one at a time depending on the button pressed, since the panels are attached).
The problem I have is that pressing the second button, for example, shows me the panel on the right blank (as if all the panels contained in it were hidden) but when I press the first one to go back to the main section I shows the panel corresponding to the second button.
Code:
//Segundo boton
private void btnDatosGenerales_Click(object sender, EventArgs e)
{
OcultarOtrosPaneles(panDatosGen);
}
// Primer boton
private void btnDatosPersonales_Click(object sender, EventArgs e)
{
OcultarOtrosPaneles(panDatosPer);
}
private void OcultarOtrosPaneles(Panel panelActivo)
{
foreach (Panel panel in this.splPrincipal.Panel2.Controls.OfType<Panel>())
{
panel.Visible = false;
}
panelActivo.Visible = true;
}
Things I tried:
- Cool the panels (with Refresh ()).
- Pass the "panelActive" parameter as a reference.
- Use the BringToFront () or SendToBack () method with the panels as appropriate.
Any ideas or suggestions?