Splitter in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes the Splitter control


Splitter

This control provides the thin strip that users can grab to resize the two panels of a SplitContainer, but you can also use it directly to separate any two other controls.

You use the Dock property and stacking order of the two controls and the Splitter to determine how the Splitter behaves.

Let's build a simple vertical splitter between two Panel controls.

Add the first Panel to the form and set its Dock property to Left so that it fills the left side of the form.

Dock Property

panel one

Then, add the Splitter control. By default, its Dock property is also Left, so it attaches to the right side of the Panel.

Finally, add the second Panel control, and set its Dock property to Fill so that it fills the rest of the form.

Voila! Now, when you drag the Splitter, Visual Basic adjusts the Panel controls accordingly.

example

You can use multiple Splitter controls to separate more than two controls.

However, it's way easier to use the SplitContainer control than to use Splitter, so use the SplitContainer when you have straightforward needs, and use the Splitter only if you need to e.g. divide a form among three Panel controls.

Previous Lesson | Next Lesson


Share This

Subscribe