Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Collapsible Splitter control in C#

, 26 Aug 2003 Ms-PL
A Mozilla-style collapsing splitter control in C#
collapsiblesplitter.zip
App.ico
collapsiblesplittercsharp.zip
CollapsibleSplitter
CollapsibleSplitterCSharp
CollapsibleSplitter.bmp
CollapsibleSplitter.csproj.user
CollapsibleSplitterTest
CollapsibleSplitterTest.csproj.user
App.ico
collapsiblesplitterdemo.zip
CollapsibleSplitterTest.exe
CollapsibleSplitter.dll
collapsiblesplitterv1.2_demo.zip
CollapsibleSplitter.exe
collapsiblesplitterv1.2_src.zip
App.ico
CollapsibleSplitter.csproj.user
collapsiblesplitter_demo.zip
CollapsibleSplitter.exe
collapsiblesplitter_src.zip
App.ico
CollapsibleSplitter.csproj.user
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Furty.Windows.Forms
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBarButton toolBarButtonToggle1;
		private System.Windows.Forms.ToolBarButton toolBarButtonToggle2;
		private System.Windows.Forms.ImageList imageList2;
		private System.Windows.Forms.MainMenu mainMenu;
		private System.Windows.Forms.StatusBar statusBar;
		private System.Windows.Forms.ToolBar toolBar;
		private System.Windows.Forms.RichTextBox richTextBox;
		private Furty.Windows.Forms.CollapsibleSplitter splitterPanelRight;
		private System.Windows.Forms.Panel panelRight;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.RadioButton radioButton3;
		private System.Windows.Forms.RadioButton radioButton2;
		private System.Windows.Forms.RadioButton radioButton1;
		private Furty.Windows.Forms.CollapsibleSplitter splitterTreeView;
		private System.Windows.Forms.TreeView treeView;
		private System.ComponentModel.IContainer components;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.mainMenu = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.statusBar = new System.Windows.Forms.StatusBar();
			this.toolBar = new System.Windows.Forms.ToolBar();
			this.toolBarButtonToggle1 = new System.Windows.Forms.ToolBarButton();
			this.toolBarButtonToggle2 = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.imageList2 = new System.Windows.Forms.ImageList(this.components);
			this.richTextBox = new System.Windows.Forms.RichTextBox();
			this.splitterPanelRight = new Furty.Windows.Forms.CollapsibleSplitter();
			this.panelRight = new System.Windows.Forms.Panel();
			this.button1 = new System.Windows.Forms.Button();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.radioButton3 = new System.Windows.Forms.RadioButton();
			this.radioButton2 = new System.Windows.Forms.RadioButton();
			this.radioButton1 = new System.Windows.Forms.RadioButton();
			this.splitterTreeView = new Furty.Windows.Forms.CollapsibleSplitter();
			this.treeView = new System.Windows.Forms.TreeView();
			this.panelRight.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// mainMenu
			// 
			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2});
			this.menuItem1.Text = "&File";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "E&xit";
			// 
			// statusBar
			// 
			this.statusBar.Location = new System.Drawing.Point(0, 259);
			this.statusBar.Name = "statusBar";
			this.statusBar.ShowPanels = true;
			this.statusBar.Size = new System.Drawing.Size(520, 22);
			this.statusBar.TabIndex = 0;
			this.statusBar.Text = "statusBar1";
			// 
			// toolBar
			// 
			this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																					   this.toolBarButtonToggle1,
																					   this.toolBarButtonToggle2});
			this.toolBar.DropDownArrows = true;
			this.toolBar.ImageList = this.imageList1;
			this.toolBar.Name = "toolBar";
			this.toolBar.ShowToolTips = true;
			this.toolBar.Size = new System.Drawing.Size(520, 33);
			this.toolBar.TabIndex = 1;
			this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
			// 
			// toolBarButtonToggle1
			// 
			this.toolBarButtonToggle1.ImageIndex = 0;
			this.toolBarButtonToggle1.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
			this.toolBarButtonToggle1.ToolTipText = "Toggle the first CollapsibleSplitter";
			// 
			// toolBarButtonToggle2
			// 
			this.toolBarButtonToggle2.ImageIndex = 0;
			this.toolBarButtonToggle2.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
			this.toolBarButtonToggle2.ToolTipText = "Toggle the second CollapsibleSplitter";
			// 
			// imageList1
			// 
			this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imageList1.ImageSize = new System.Drawing.Size(24, 24);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// imageList2
			// 
			this.imageList2.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imageList2.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList2.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList2.ImageStream")));
			this.imageList2.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// richTextBox
			// 
			this.richTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
			this.richTextBox.Location = new System.Drawing.Point(168, 33);
			this.richTextBox.Name = "richTextBox";
			this.richTextBox.Size = new System.Drawing.Size(192, 226);
			this.richTextBox.TabIndex = 11;
			this.richTextBox.Text = "Collapsible Splitter Control by Furty";
			// 
			// splitterPanelRight
			// 
			this.splitterPanelRight.ControlToHide = this.panelRight;
			this.splitterPanelRight.Dock = System.Windows.Forms.DockStyle.Right;
			this.splitterPanelRight.ExpandParentForm = true;
			this.splitterPanelRight.Location = new System.Drawing.Point(360, 33);
			this.splitterPanelRight.Name = "splitterPanelRight";
			this.splitterPanelRight.ParentForm = this;
			this.splitterPanelRight.Size = new System.Drawing.Size(8, 226);
			this.splitterPanelRight.TabIndex = 10;
			this.splitterPanelRight.TabStop = false;
			this.splitterPanelRight.VisualStyle = Furty.Windows.Forms.CollapsibleSplitter.VisualStyles.DoubleDots;
			// 
			// panelRight
			// 
			this.panelRight.BackColor = System.Drawing.SystemColors.Control;
			this.panelRight.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.panelRight.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.button1,
																					 this.groupBox1});
			this.panelRight.Dock = System.Windows.Forms.DockStyle.Right;
			this.panelRight.Location = new System.Drawing.Point(368, 33);
			this.panelRight.Name = "panelRight";
			this.panelRight.Size = new System.Drawing.Size(152, 226);
			this.panelRight.TabIndex = 9;
			// 
			// button1
			// 
			this.button1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.button1.Location = new System.Drawing.Point(8, 136);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(124, 23);
			this.button1.TabIndex = 2;
			this.button1.Text = "A Button";
			// 
			// groupBox1
			// 
			this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.radioButton3,
																					this.radioButton2,
																					this.radioButton1});
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(132, 120);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Some radio buttons";
			// 
			// radioButton3
			// 
			this.radioButton3.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.radioButton3.Location = new System.Drawing.Point(16, 88);
			this.radioButton3.Name = "radioButton3";
			this.radioButton3.TabIndex = 2;
			this.radioButton3.Text = "radioButton3";
			// 
			// radioButton2
			// 
			this.radioButton2.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.radioButton2.Location = new System.Drawing.Point(16, 56);
			this.radioButton2.Name = "radioButton2";
			this.radioButton2.TabIndex = 1;
			this.radioButton2.Text = "radioButton2";
			// 
			// radioButton1
			// 
			this.radioButton1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.radioButton1.Location = new System.Drawing.Point(16, 24);
			this.radioButton1.Name = "radioButton1";
			this.radioButton1.TabIndex = 0;
			this.radioButton1.Text = "radioButton1";
			// 
			// splitterTreeView
			// 
			this.splitterTreeView.ControlToHide = this.treeView;
			this.splitterTreeView.ExpandParentForm = true;
			this.splitterTreeView.Location = new System.Drawing.Point(160, 33);
			this.splitterTreeView.Name = "splitterTreeView";
			this.splitterTreeView.ParentForm = null;
			this.splitterTreeView.Size = new System.Drawing.Size(8, 226);
			this.splitterTreeView.TabIndex = 8;
			this.splitterTreeView.TabStop = false;
			this.splitterTreeView.VisualStyle = Furty.Windows.Forms.CollapsibleSplitter.VisualStyles.Mozilla;
			// 
			// treeView
			// 
			this.treeView.Dock = System.Windows.Forms.DockStyle.Left;
			this.treeView.ImageList = this.imageList2;
			this.treeView.Location = new System.Drawing.Point(0, 33);
			this.treeView.Name = "treeView";
			this.treeView.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
																				 new System.Windows.Forms.TreeNode("Desktop", 0, 0, new System.Windows.Forms.TreeNode[] {
																																											new System.Windows.Forms.TreeNode("My Computer", 1, 1, new System.Windows.Forms.TreeNode[] {
																																																																		   new System.Windows.Forms.TreeNode("Floppy Drive (A:)", 2, 2),
																																																																		   new System.Windows.Forms.TreeNode("Hard Drive (C:)", 3, 3),
																																																																		   new System.Windows.Forms.TreeNode("DVD/CD-RW Drive (D:)", 4, 4),
																																																																		   new System.Windows.Forms.TreeNode("Shared Documents", 8, 8)}),
																																											new System.Windows.Forms.TreeNode("My Documents", 5, 5),
																																											new System.Windows.Forms.TreeNode("My Network Places", 6, 6),
																																											new System.Windows.Forms.TreeNode("Recycle Bin", 7, 7)})});
			this.treeView.Size = new System.Drawing.Size(160, 226);
			this.treeView.TabIndex = 7;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(520, 281);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.richTextBox,
																		  this.splitterPanelRight,
																		  this.panelRight,
																		  this.splitterTreeView,
																		  this.treeView,
																		  this.toolBar,
																		  this.statusBar});
			this.Menu = this.mainMenu;
			this.Name = "Form1";
			this.Text = "Collapsible Splitter Control for .NET";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.panelRight.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.treeView.Nodes[0].ExpandAll();
		}

		private void splitterTreeView_Click(object sender, System.EventArgs e)
		{
			this.toolBarButtonToggle1.Pushed = this.splitterTreeView.IsCollapsed;
		}

		private void splitterPanelRight_Click(object sender, System.EventArgs e)
		{
			this.toolBarButtonToggle2.Pushed = this.splitterPanelRight.IsCollapsed;
		}

		private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			switch(toolBar.Buttons.IndexOf(e.Button))
			{
				case 0:
					this.splitterTreeView.ToggleState();
					this.toolBarButtonToggle1.Pushed = this.splitterTreeView.IsCollapsed;
					break;
				case 1:
					this.splitterPanelRight.ToggleState();
					this.toolBarButtonToggle2.Pushed = this.splitterPanelRight.IsCollapsed;
					break;
			}

		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Furty
Web Developer
Thailand Thailand
Furty will code for food.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 27 Aug 2003
Article Copyright 2002 by Furty
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid