Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleProgrammatically adjust the position of the splitter in a SplitContainer control in Visual Basic .NET
DescriptionThis example shows how to programmatically adjust the position of the splitter in a SplitContainer control in Visual Basic .NET.
Keywordssplitter, SplitContainer, adjust splitter, controls, programming, example, example program, Windows Forms programming, Visual Basic .NET, VB.NET
CategoriesControls
 
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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated