using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { CollapsiblePanel cp = new CollapsiblePanel(); this.Controls.Add(cp); } } // public class CollapsiblePanel : SplitContainer { public Button OpenCloseButton; public TextBox TextBox; public CollapsiblePanel() { this.Orientation = Orientation.Horizontal; this.IsSplitterFixed = false; this.OpenCloseButton = new Button(); this.OpenCloseButton.Dock = DockStyle.Fill; this.OpenCloseButton.Click += new EventHandler(_OpenCloseButton_Click); this.Panel1.Controls.Add(OpenCloseButton); this.TextBox = new TextBox(); this.TextBox.Multiline = true; this.TextBox.Dock = DockStyle.Fill; this.Panel2.Controls.Add(TextBox); } void CollapsiblePanel_SizeChanged(object sender, EventArgs e) { } void _OpenCloseButton_Click(object sender, EventArgs e) { this.Panel2Collapsed = !this.Panel2Collapsed; } } }