Splitter Control in C#

 

In C# Windows applications Splitter control used to resize the other controls. That means by using Splitter control we can adjust the size of the other control. For example you have a lot of control on win form and you want to move some controls to side once you finished work to save some space, use to splitter control to resize them. When we run the application the Splitter control is invisible but if you place mouse on the Splitter control it indicates as resizable control.

 

We discuss about Splitter control with some example. Open Microsoft Visual Studio => Create Some Windows Application and name it as CSharpSplitter.

 

First Add Panel with some controls and change the Dock property to Left. Then add Splitter control, change Dock property of splitter control also to Left. To make Splitter control works, both splitter control Dock property and actual control Dock property(here Panel) has to be same.

 

Change the Splitter control properties as shown below.

           

           this.splitter1.BackColor = System.Drawing.SystemColors.ActiveBorder;

            this.splitter1.Location = new System.Drawing.Point(281, 0);

            this.splitter1.Name = "splitter1";

            this.splitter1.Size = new System.Drawing.Size(20, 371);

            this.splitter1.TabIndex = 1;

            this.splitter1.TabStop = false;

 

Now add one more panel with some controls and execute the application. The output is as shown below.

 

Place the mouse on Splitter control and try to resize it as shown below.

 

           

 

Splitter control is very useful when we are working with controls both at design-time and run-time.

 

                     

                                                                                                            CSharpSplitter.zip (41.45 kb)