Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SplitContainer Class

Represents a control consisting of a movable bar that divides a container's display area into two resizable panels.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public class SplitContainer extends ContainerControl

You can add controls to the two resizable panels, and you can add other SplitContainer controls to existing SplitContainer panels to create many resizable display areas.

Use the SplitContainer control to divide the display area of a container (such as a Form) and allow the user to resize controls that are added to the SplitContainer panels. When the user passes the mouse pointer over the splitter, the cursor changes to indicate that the controls inside the SplitContainer control can be resized.

NoteNote:

Previous versions of the .NET Framework only support the Splitter control.

SplitContainer also eases control placement at design time. For example, to create a window similar to Windows Explorer, add a SplitContainer control to a Form and set its Dock property to DockStyle.Fill. Add a TreeView control to the Form and set its Dock property to DockStyle.Fill. To complete the layout, add a ListView control and set its Dock property to DockStyle.Fill to have the ListView occupy the remaining space on the Form. At run time, the user can then resize the width of both controls using the splitter. Use the FixedPanel property to specify that a control should not be resized along with the Form or other container.

Use SplitterDistance to specify where the splitter starts on your form. Use SplitterIncrement to specify how many pixels the splitter moves at a time. The default for SplitterIncrement is one pixel.

Use Panel1MinSize and Panel2MinSize to specify how close the splitter bar can be moved to the outside edge of a SplitContainer panel. The default minimum size of a panel is 25 pixels.

Use the Orientation property to specify horizontal orientation. The default orientation of the SplitContainer is vertical.

Use the BorderStyle property to specify the border style of the SplitContainer and coordinate its border style with the border style of controls that you add to the SplitContainer.

The following code example shows both a vertical and horizontal SplitContainer. The vertical splitter moves in 10-pixel increments. The left panel of the vertical SplitContainer contains a TreeView control, and its right panel contains a horizontal SplitContainer. Both panels of the horizontal SplitContainer are filled with ListView controls, and the top panel is defined as a FixedPanel so that it does not resize when you resize the container. Moving the vertical splitter raises the SplitterMoving event, signified in this example by a change to the cursor style. The SplitterMoved event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default.

No code example is currently available or this language may not be supported.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft