GroupBox in Visual Basic .NET

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

This lesson describes the GroupBox control


GroupBox

To move a control in the Windows Forms Designer is very easy. Just click and drag the control to its new position. In addition you can drag controls in and out of container controls (controls that contain, group, and help arrange other controls).

These controls include FlowLayoutPanel, TableLayoutPanel, GroupBox, Panel, TabControl, and SplitContainer.

The GroupBox control is good for grouping related controls or the RadioButton controls in a RadioButton group. This control provides a visible border and caption which can help the user when works with a complicated form containing lot of controls. In other words, it makes the interface much easier for the user to understand.

GroupBox displays a border and caption which is good for decoration and visual appealing.

example

One of the best things about this control is that if you set its Enabled property to False, then the controls it contains are also disabled, and it is a perfect way to enable or disable a group of controls all at once.

Another useful feature is that its Controls property, returns a collection containing references to all controls inside the GroupBox, which allows you to change those controls without affecting the other controls on the form. e.g. say we want to change the font of all label controls inside the GroupBox2:

    For Each ctrl As Control In GroupBox2.Controls
        If TypeOf ctrl Is Label Then
            DirectCast(ctrl, Label).Font = New Font("Arial", 10, FontStyle.Bold)
        End If
    Next


font example

Previous Lesson | Next Lesson


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.