Timothy Khouri
Timothy Khouri

Reputation: 31845

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?

Upvotes: 3

Views: 1914

Answers (2)

itsmatt
itsmatt

Reputation: 31406

To hide one of the panels you can call

MyPanel.Panel1Collapsed = true; // or Panel2Collapsed

If Panel2 was collapsed, it will toggle its state to be shown after this call.

MSDN Reference

Upvotes: 2

Ron Warholic
Ron Warholic

Reputation: 10074

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

Upvotes: 5

Related Questions