GroupBox.FlatStyle Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the flat style appearance of the group box control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public FlatStyle FlatStyle { get; set; }

Property Value

Type: System.Windows.Forms.FlatStyle

One of the FlatStyle values. The default value is Standard.

Exception Condition
InvalidEnumArgumentException

The value assigned is not one of the FlatStyle values.

A GroupBox with a FlatStyle value of System does not receive mouse events.

The following code example instantiates and creates a GroupBox and two RadioButton controls. The option buttons (also known as radio buttons) are added to the group box and the group box is added to the Form.

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);
}

.NET Framework
Available since 1.1
Return to top
Show: