可伸缩的Form窗体!

希望实现窗体的可折叠!像ArcToolBox中的窗体一下,点击显示帮助,窗体显示,点击收缩,窗体折叠。

窗体部件:

Panel控件,CheckBox控件

将Panel控件布置到窗体的右面,停靠

在FormLoad事件中输入下面代码:

 panel1.Visible = false;
 this.Width = this.Width - panel1.Width;

在checkBox的CheckedOnChange事件中输入下面代码:

private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            panel1.Visible = !panel1.Visible;
            if (panel1.Visible)
            {
                this.Width = this.Width + panel1.Width;
            }
            else
            {
                this.Width = this.Width - panel1.Width;
            }
        }

这样,窗体默认折叠,选择CheckBox1,窗体伸展。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
  • 2021-12-18
  • 2021-10-02
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-01
  • 2021-11-26
  • 2021-07-04
  • 2022-12-23
  • 2021-10-22
相关资源
相似解决方案