GroupBox.FlatStyle 屬性

定義

取得或設定群組方塊控制項的平面樣式外觀。Gets or sets the flat style appearance of the group box control.

public:
 property System::Windows::Forms::FlatStyle FlatStyle { System::Windows::Forms::FlatStyle get(); void set(System::Windows::Forms::FlatStyle value); };
public System.Windows.Forms.FlatStyle FlatStyle { get; set; }
member this.FlatStyle : System.Windows.Forms.FlatStyle with get, set
Public Property FlatStyle As FlatStyle

屬性值

其中一個 FlatStyle 值。One of the FlatStyle values. 預設值為 StandardThe default value is Standard.

例外狀況

所指派的值不是其中一個 FlatStyle 值。The value assigned is not one of the FlatStyle values.

範例

下列程式碼範例會具現化並建立 GroupBox 和兩個 @no__t 1 控制項。The following code example instantiates and creates a GroupBox and two RadioButton controls. 選項按鈕(也稱為選項按鈕)會加入至 [群組] 方塊,而 [群組] 方塊則會加入至 [Form]。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);
}
 
Private Sub InitializeMyGroupBox()
   ' Create and initialize a GroupBox and a Button control.
        Dim groupBox1 As New GroupBox()
        Dim button1 As 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.
        Dim groupBox2 As New GroupBox()
        Dim button2 As 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)
End Sub 

備註

具有 FlatStyleSystemGroupBox 不會收到滑鼠事件。A GroupBox with a FlatStyle value of System does not receive mouse events.

適用於

另請參閱