A group box is a rectangular object used to hold and
carry child controls. To show its presence, a group box displays a lined
border. It can be used for aesthetic reasons or as a container. As a
graphical object, a group box is surrounded by a chiseled border that sets
it apart from other controls on the form or frame. When acting as a
container, a group box serves as host and parent to controls positioned
inside its borders.

To show what it is used for, especially when it acts as
a parent, a group displays a title in its top border, but this is an
optional feature determined by the programmer.

Creating a Group Box

In the Win32 library, a group box is in the group of
static controls. To support group boxes, the VCL provides a class named
TGroupBox. The TGroupBox class is based on
the TCustomGroupBox class. Both classes are defined in the
StdCtrls.hpp header file. The TCustomGroupBox class
is derived from TCustomControl.

The TCustomControl class is based on
the TWinControl class:

To visually create a group box, in the Standard section
of the Tool Palette, click the TGroupBox icon and click the
form. To dynamically get a group box, create a pointer to TGroupBox.
Use its constructor to specify its owner and assign its own container to the
Parent property. This would be done as follows:

A mentioned already, a group box can be used as a
rectangular object that displays a chiseled border. This characteristic
makes it possible to create various sections on the form or frame for
aesthetic reasons. If you use one group box just for this reason, it may not
need a title. Most of the time, if you add many group boxes to your
application, even if you use only one group box, you can add a title to show
what the group box is used for.

If you visually create a group box, it automatically
gets a title, which displays in its top border. To change that title, access
the Object Inspector for the group box, click Caption, and type the desired
value. If you programmatically create a group box, by default, it doesn't
receive a title. Fortunately, the TGroupBox class gets the
Caption property from the TControl class, one of its
ancestors. Therefore, to programmatically specify or change the title of a
group box, assign the desired string to its Caption
property. This can be done as follows: