ARTICLE

GroupBox control in WPF using VB.NET

Posted by Rohatash Kumar Articles | WPF using VB.NET January 31, 2011
In this article we will learn how to use GroupBox control in WPF using VB.NET.
Download Files:
 
Reader Level:

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.

gp1.gif

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.

gp2.gif

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.


gp3.gif 

Figure 3.

Foreground and Background property

BackColor and ForeColor properties are used to set background and foreground color of a GroupBox control.

gp4.gif

 Figure 4.

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor