Collapsing and Expanding SplitContainer panels
Asked Answered
C

1

5

I have 3 split containers in my winform application. splitContainer1, splitContainer2, splitContainer3

splitContainer1 is the main split container. in it's panel1 I put splitContainer2 and in its panel2 I have splitContainer3

I then added two buttons to collapse/hide splitContainer3 panels: whenever I click on a button, it gets collapsed, but when I want 2 panels be collapsed, one of them automatically gets expanded again What can be the problem?

private void btToggleCI_Click(object sender, EventArgs e)
{
    switch (splitContainer3.Panel1Collapsed)
    {
        case false:

            splitContainer3.Panel1Collapsed = true;
            btToggleCI.ForeColor = Color.Gray;

            break;

        case true:

            splitContainer3.Panel1Collapsed = false;
            btToggleCI.ForeColor = Color.Black;

            break;
    }
}

private void btToggleTestPlan_Click(object sender, EventArgs e)
{
    switch (splitContainer3.Panel2Collapsed)
    {
        case false:

            splitContainer3.Panel2Collapsed = true;
            btToggleTestPlan.ForeColor = Color.Gray;

            break;

        case true:

            splitContainer3.Panel2Collapsed = false;
            btToggleTestPlan.ForeColor = Color.Black;

            break;
    }
}
Capp answered 8/12, 2011 at 14:27 Comment(0)
B
9

A SplitContainerControl can have up to one panel collapsed.

You can't collapse both panels simultaneously (what would that look like?).

Bareheaded answered 8/12, 2011 at 14:29 Comment(2)
Damn! haha...So what would be the workaround? I want when both buttons are pressed the splitcontainer somehow be vanished! any ideas?Capp
@Sean87: .Visible = false?Bareheaded

© 2022 - 2024 — McMap. All rights reserved.