|
|
Title | Programmatically adjust the position of the splitter in a SplitContainer control in Visual Basic .NET |
Description | This example shows how to programmatically adjust the position of the splitter in a SplitContainer control in Visual Basic .NET. |
Keywords | splitter, SplitContainer, adjust splitter, controls, programming, example, example program, Windows Forms programming, Visual Basic .NET, VB.NET |
Categories | Controls |
|
|
You can use the SplitContainer's Panel1Collapsed and Panel2Collapsed properties to collapse one of the panels and make it disappear. While a panel is collapsed, the user cannot adjust the splitter.
The following code makes the left panel disappear in a horizontal SplitContainer.
|
|
SplitContainer1.Panel1Collapsed = true;
|
|
To set the splitter to a particular position, set the SplitContainer's SplitterDistance property. Be sure to un-collapse any panels that you may have collapsed.
The following code moves the splitter to 25% of the way through the SplitContainer.
|
|
SplitContainer1.Panel1Collapsed = false;
SplitContainer1.Panel2Collapsed = false;
SplitContainer1.SplitterDistance = _
(int)(SplitContainer1.ClientSize.Width * 0.25);
|
|
In the example program, click the buttons to collapse a panel or move the splitter to 25%, 50%, or 75% of the way through the SplitContainer.
|
|
|
|
|
|