How can I hide a panel that is on a SplitContainer?

I want to hide panel2 on a split container and have panel1 utilize the space. I was hoping setting Panel2Collapsed would do the trick, but no luck. Ideas?


Solution 1:

This worked for me on a similar situation:

splitContainer1.Panel2Collapsed = true;
splitContainer1.Panel2.Hide();

I wanted the second panel to not be visible at all in some cases, so I implemented it this way.

Solution 2:

Setting Panel2Collapsed property to true in the form designer and programatically both work as you want them to (i.e. Panel1 then occupies all of the space)... so there must be something else going on.

Solution 3:

            this.splitContainerControl1.Panel2.Hide();
            this.splitContainerControl1.Panel2.Height = 0;
            this.splitContainerControl1.IsSplitterFixed = true; 

This worked for me.

Solution 4:

splitContainer1.PanelVisibility = SplitPanelVisibility.Panel1