Search code examples
.netwinformssplitcontainer

With the .NET "WinForms" SplitContainer control, how can I hide a panel dynamically?


Calling MyPanel.Panel1.Hide(); or MyPanel.Panel2.Hide(); simply hides the controls inside the panel... but I want to have the other side of the panel fill up the whole space.

So, if I hide Panel1, I want Panel2 to take up the whole space, and I want the splitter to disappear. Is that possible, if so, how?


Solution

  • Use MyPanel.Panel1Collapsed = true; to collapse Panel1 (likewise for panel2).