希望实现窗体的可折叠!像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,窗体伸展。