70-526 MCTSGroupBox controlThe GroupBox control displays a frame around a group of controls with or without a caption. GroupBoxes are used to subdivide a form by function, giving the user a logical visual cue of control grouping. You can add controls to the GroupBox at design time and runtime. When you move the GroupBox control, all of its contained controls move too. When you create a new group box, it has a border by default, and its caption is set to the name of the control. ![]() Inheritance hierarchySystem.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.GroupBox
Useful propertiesNote Add a control to a GroupBox manuallyThe MSDN page has the following example showing how to add a GroupBox and some controls within it. private void InitializeMyGroupBox()
{
// Create and initialize a GroupBox and a Button control.
GroupBox groupBox1 = new GroupBox();
Button button1 = new Button();
button1.Location = new Point(20,10);
// Set the FlatStyle of the GroupBox.
groupBox1.FlatStyle = FlatStyle.Flat;
// Add the Button to the GroupBox.
groupBox1.Controls.Add(button1);
// Add the GroupBox to the Form.
Controls.Add(groupBox1);
// Create and initialize a GroupBox and a Button control.
GroupBox groupBox2 = new GroupBox();
Button button2 = new Button();
button2.Location = new Point(20, 10);
groupBox2.Location = new Point(0, 120);
// Set the FlatStyle of the GroupBox.
groupBox2.FlatStyle = FlatStyle.Standard;
// Add the Button to the GroupBox.
groupBox2.Controls.Add(button2);
// Add the GroupBox to the Form.
Controls.Add(groupBox2);
}
MSDN references
|