I have a form in Visual Studio 2010 that consists of a listbox and multple frames.
The Frames are all put on top of each other, with the listbox above the frames. The process that I am trying to accomplish is that depending on which report you pick in the lisbox, a certain frame will appear, and only that frame.
I have the following code to accomplish this:
switch (Convert.ToInt32(item.Value))
{
case 11:
fraSelect_2.Hide();
fraSelect_3.Hide();
fraSelect_4.Hide();
fraSelect_1.Visible = true;
iCounter = 1;
break;
case 12:
fraSelect_1.Hide();
fraSelect_3.Hide();
fraSelect_4.Hide();
fraSelect_2.Visible = true;
iCounter = 2;
break;
}
And so on for each case. The problem that I am having is that if the frame I am calling is underneath a different frame (that is not visible) it won’t show. Although when I select the report corresponding to the top form it will work. So if report1 = frame1 when I select report1 I can see frame1. But if I select report2 I get nothing because frame2 is behind a non visible frame1.
Any idea on how I can get the frames behind frame1 to show once the corresponding report is selected?
In design mode put each groupbox in a separate Location and check that they are not contained in another groupbox. Leave one groupbox in the desidered position with the required size.
Then in the Load event of your form reposition every groupbox at the same location of the one used as placeholder.
then simply setting Visible=true/false (no Hide() or BringToFront()) should be enough to show the correct one.
The problem is caused by the fact that when you drop the groupbox on the top of another groupbox, the last one, becomes a child of the first and if the top level group box is hidden then all of its childs are automatically hidden by Windows and you can’t make them visible in any way.