A GroupBox control is a container control that is used to place Windows Forms child controls in a group. The purpose of a GroupBox is to define user interfaces where we can categorize related controls in a group.
In this article, I will discuss how to create a GroupBox control in Windows Forms at design-time as well as run-time. After that, I will discuss various properties and methods available for the GroupBox control.
Creating a GroupBox
We can create a GroupBox control using a Forms designer at design-time or using the GroupBox class in code at run-time (also known as dynamically).
To create a GroupBox control at design-time, you simply drag and drop a GroupBox control from Toolbox to a Form in Visual Studio. After you drag and drop a GroupBox on a Form, the GroupBox looks like Figure 1. Once a GroupBox is on the Form, you can move it around and resize it using the mouse and set its properties and events.
In this article, I will discuss how to create a GroupBox control in Windows Forms at design-time as well as run-time. After that, I will discuss various properties and methods available for the GroupBox control.
Creating a GroupBox
We can create a GroupBox control using a Forms designer at design-time or using the GroupBox class in code at run-time (also known as dynamically).
To create a GroupBox control at design-time, you simply drag and drop a GroupBox control from Toolbox to a Form in Visual Studio. After you drag and drop a GroupBox on a Form, the GroupBox looks like Figure 1. Once a GroupBox is on the Form, you can move it around and resize it using the mouse and set its properties and events.

Figure 1
Creating a GroupBox control at run-time is merely a work of creating an instance of GroupBox class, setting its properties and adding GroupBox class to the Form controls.
First step to create a dynamic GroupBox is to create an instance of GroupBox class. The following code snippet creates a GroupBox control object.
First step to create a dynamic GroupBox is to create an instance of GroupBox class. The following code snippet creates a GroupBox control object.
- GroupBox authorGroup = newGroupBox();
In the next step, you may set properties of a GroupBox control. The following code snippet sets background color, foreground color, Text, Name, and Font properties of a GroupBox.
- authorGroup.Name = "GroupBox1";
- authorGroup.BackColor = Color.LightBlue;
- authorGroup.ForeColor = Color.Maroon;
- authorGroup.Text = "Author Details";
- authorGroup.Font = newFont("Georgia", 12);
Once a GroupBox control is ready with its properties, next step is to add the GroupBox control to the Form. To do so, we use Form.Controls.Add method. The following code snippet adds a GroupBox control to the current Form.
- this.Controls.Add(authorGroup);


Mahesh ChandPosted Sep 7, 2018, 7:02 AM
Article updated - Formatted
minh quanPosted Apr 26, 2018, 11:26 PM
If i wanna change color title groupbox but my button inside group box must be not change ?
z nePosted Mar 5, 2018, 7:17 AM
For (int i = 0; i < 5; i++) { g[i] = new GroupBox(); g[i].Location = new Point(100, i * 60 + 100); g[i].Height = 59; g[i].Width = 710; Controls.Add(g[i]); for (int j = 0; j < 4; j++) { r[j] = new RadioButton(); r[j].Location = new Point(j * 150 + 110, i * 60 + 110); g[i].Controls.Add(r[j]); } }
z nePosted Mar 5, 2018, 7:17 AM
Hello. i want to add an array of radio button to a groupbox and the code is as below. but my radio buttons cant be shown
Manish JainPosted Aug 5, 2015, 4:20 AM
Hello sir, is it possible to set the group box title in the middle?
Mahesh ChandPosted Jul 5, 2010, 11:40 AM
This is a test comment