简体   繁体   English

以Win形式C#扩展collpase splitcontainer

[英]Expand collpase splitcontainer in win form c#

i am working with split container. 我正在使用拆分容器。 my split container has two panel and horizontal orientation. 我的拆分容器有两个面板和水平方向。 in first panel there are some textboxes and one button. 在第一个面板中,有一些文本框和一个按钮。 when i click on button then a code run to collapse Panel1 of split container. 当我单击按钮时,代码运行以折叠拆分容器的Panel1。 code is like 代码就像

 private void button1_Click(object sender, EventArgs e)
 {
        splitContainer1.Panel1Collapsed = !splitContainer1.Panel1Collapsed; 
 }

my problem is when collapse occur then my button and all the textboxes getting invisible. 我的问题是当崩溃发生时,我的按钮和所有文本框都变得不可见。 so i next time not being able to make those control visible. 所以下一次我将无法使那些控件可见。 so i want trick like button will not be invisible as a result i can click on that button again to make panel1 visible. 所以我想要像按钮一样的技巧不会不可见,因此我可以再次单击该按钮以使panel1可见。 if possible guide me how to fix or place my button on splitter rather on panel. 如果可能的话,指导我如何固定或将按钮放在分离器上,而不是放在面板上。 so guide me how can i do it. 所以指导我该怎么做。

private void button1_Click(object sender, EventArgs e)
{
    splitContainer1.Panel1Collapsed = !splitContainer1.Panel1Collapsed;
    button1.Parent = splitContainer1.Panel1Collapsed ? splitContainer1.Panel2 : splitContainer1.Panel1;
}

Related to my previous comment on your entire posting. 与我之前对您的整个帖子发表的评论有关。 this is a small solution with a ToolBarButton . 这是一个带有ToolBarButton的小解决方案。 It will only be enabled if the SplitContainer.Panel1 is collapsed. 仅当SplitContainer.Panel1折叠时才启用。

Code: 码:

    private void Form1_Load(object sender, EventArgs e)
    {
        splitContainer1.Panel1Collapsed = true;
        toolStripButton1.Enabled = true;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        splitContainer1.Panel1.Hide();
        toolStripButton1.Enabled = true;
    }

    private void toolStripButton1_Click(object sender, EventArgs e)
    {
        if (splitContainer1.Panel1Collapsed)
        {
            toolStripButton1.Enabled = false;
            splitContainer1.Panel1.Show();
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM