Member Avatar


I'm trying to have my panels overlap, but visual studio is placing my second panel INSIDE the main panel, I want them to be purely independent of one another. I have my main menu panel and when the user clicks a button that menu panel is disabled and changed to non visible and the other panel is enabled and made visible (and brought to front? I don't think you can do that with panels)

But what it actually happening is the menu panel is made non visible and disabled, visual studio is thinking the second panel is part of the first, consequently disabling the second panel I want displayed. I've tried building the panels in various fashions. I built the main menu panel on the form it is to be displayed in and in another testing form I made the second panel, then back on the main form (with the main form selected NOT the menu panel) I paste the second panel overlapping the menu panel, not inside it. On a button click the following code executes

panelTutorStart.Visible = false;
panelTutorStart.Enabled = false;
panelProblemDisp.Visible = true;
panelProblemDisp.Enabled = true;
labelExplain.Visible = true;

Is there a way, programmatically, that I could add and remove the panels independently instead of just changing enable/visible to avoid Visual studio thinking that the second panel should be inside the menu panel?

Place your 2 panels on the form and then in the properties pane set the location of each to be the same. They will then appear exactly on top of each other (not one inside the other) and you can alter the visibility of each as required.

Well since you use the word panel - i am assuming that you use ASP.NET ? or are you working with WinfOrms?

The approach you would use for ASP.NET would be to use

<asp:Button ID="btnClickMe" Text="Click Here to alternate between panels" onClientClick="CheckPanels(); return false;" />
<div id="divONE"></div>
<div id="divTWO"></div>

Use some javascript to set the display to either '' or 'none'.

IF You are using windows forms the approach is quite easy too.

Add two panels underneath one another and make both of their dock properties = TOP or FILL.

This will result in them being placed in the same posistion once one is made invisible.