In this article we will learn how to use
GroupBox control in WPF using VB.NET.
GroupBox control
GroupBox control is used to creates a container
that has a border and a header for user interface content. GroupBox control display a
frame around them and also allows to display captions to them which is not
possible with the Panel control.
Properties - This control has the
following properties.
You can open Properties window by pressing F4
or right click on a control and select Properties item.

Figure 1.
Header - Header property is represents
the header text of a GroupBox control.
XAML code
<GroupBox
Header="GroupBox1"
Height="175"
HorizontalAlignment="Left"
Margin="10,10,0,0"
Name="GroupBox1"
VerticalAlignment="Top"
Width="370">
Width
and height properties of the GroupBox control are used to set the width and
height of the control and Name property is the property which has the unique name of a GroupBox control.
The
form looks like this.

Figure
2.
For
example
Drag
and Drop a GroupBox control, TabControl on the form.
XAML code
<Window
x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="525">
<Grid>
<GroupBox
Header="GroupBox1"
Height="175"
HorizontalAlignment="Left"
Margin="10,10,0,0"
Name="GroupBox1"
VerticalAlignment="Top"
Width="370">
<Grid
Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="86*"
/>
<ColumnDefinition
Width="272*"
/>
</Grid.ColumnDefinitions>
<TabControl
Grid.ColumnSpan="2"
Height="133"
HorizontalAlignment="Left"
Margin="20,13,0,0"
Name="TabControl1"
VerticalAlignment="Top"
Width="303">
<TabItem
Header="Personal
Info"
Name="TabItem1">
<Grid>
<TextBlock
Height="23"
HorizontalAlignment="Left"
Margin="10,10,0,0"
Name="TextBlock1"
Text="Name-
Rohatash Kumar"
VerticalAlignment="Top"
/>
<TextBlock
Height="23"
HorizontalAlignment="Left"
Margin="10,0,0,35"
Name="TextBlock2"
Text="Email-rohatash.mca@gmail.com"
VerticalAlignment="Bottom"
/>
</Grid>
</TabItem>
<TabItem
Header="Job
Info"
Name="TabItem2">
<Grid>
<TextBlock
Height="23"
HorizontalAlignment="Left"
Margin="10,10,0,0"
Name="TextBlock3"
Text="Developer"
VerticalAlignment="Top"
/>
</Grid>
</TabItem>
<TabItem
Header="Skill"
Name="TabItem3">
<Grid>
<TextBlock
Height="23"
HorizontalAlignment="Left"
Margin="10,10,0,0"
Name="TextBlock4"
Text=".NET(c#,
visual Basic, SQL Server)"
VerticalAlignment="Top"
/>
</Grid>
</TabItem>
</TabControl>
</Grid>
</GroupBox>
</Grid>
</Window>
The form looks like this.
Figure 3.
Foreground and Background property
BackColor and
ForeColor properties are used to set background and foreground color of a
GroupBox control.
Figure 4.