Share via


GroupBox クラス

Windows グループ ボックスを表します。

この型のすべてのメンバの一覧については、GroupBox メンバ を参照してください。

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.GroupBox

Public Class GroupBox
   Inherits Control
[C#]
public class GroupBox : Control
[C++]
public __gc class GroupBox : public Control
[JScript]
public class GroupBox extends Control

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

GroupBox はキャプション付きコントロールまたはキャプションなしコントロールのグループの周りにフレームを表示します。 GroupBox を使用して、フォーム上のコントロールのコレクションを論理的にグループ化します。グループ ボックスは、コントロールのグループを定義するために使用できるコンテナ コントロールです。

グループ ボックスは、一般的に RadioButton コントロールの論理グループを格納するために使用されます。2 つのグループ ボックスのそれぞれに複数のオプション ボタンがある場合、各ボタン グループで一度に選択できるボタンは 1 つだけで、設定されるオプション値もそれぞれ 1 つです。

Controls プロパティの Add メソッドを使用して、コントロールを GroupBox に追加できます。

メモ    GroupBox コントロール内に格納されているコントロールだけが、選択またはフォーカスを受け取ることができます。 GroupBox そのものを選択したり、フォーカスを与えたりすることはできません。 Focus メソッドおよび Select メソッドに対してこのコントロールが応答する方法の詳細については、 CanFocusCanSelectFocusedContainsFocusFocusSelect の各 Control メンバのトピックを参照してください。

使用例

GroupBox と 2 つの RadioButton コントロールをインスタンス化および作成する例を次に示します。オプション ボタンはグループ ボックスに追加され、グループ ボックスは Form に追加されます。

 
Private Sub InitializeMyGroupBox()
   ' Create and initialize a GroupBox and two RadioButton controls.
   Dim groupBox1 As New GroupBox()
   Dim radioButton1 As New RadioButton()
   Dim radioButton2 As New RadioButton()

   ' Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System    
        
   ' Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1)
   groupBox1.Controls.Add(radioButton2)
        
   ' Add the GroupBox to the Form.
    Controls.Add(groupBox1)
End Sub 'InitializeMyGroupBox

[C#] 
private void InitializeMyGroupBox()
{
   // Create and initialize a GroupBox and two RadioButton controls.
   GroupBox groupBox1 = new GroupBox();
   RadioButton radioButton1 = new RadioButton();
   RadioButton radioButton2 = new RadioButton();

   // Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System;
 
   // Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1);
   groupBox1.Controls.Add(radioButton2);
 
   // Add the GroupBox to the Form.
   Controls.Add(groupBox1);
}
 

[C++] 
private:
    void InitializeMyGroupBox() {
        // Create and initialize a GroupBox and two RadioButton controls.
        GroupBox __gc *groupBox1 = new GroupBox();
        RadioButton __gc *radioButton1 = new RadioButton();
        RadioButton __gc *radioButton2 = new RadioButton();
     
        // Add the RadioButtons to the GroupBox.
        groupBox1->Controls->Add(radioButton1);
        groupBox1->Controls->Add(radioButton2);
 
        // Add the GroupBox to the Form.
        Controls->Add(groupBox1);
    };
 

[JScript] 
function InitializeMyGroupBox(){
   // Create and initialize a GroupBox and two RadioButton controls.
   var groupBox1 : GroupBox = new GroupBox()
   var radioButton1 : RadioButton = new RadioButton()
   var radioButton2 : RadioButton = new RadioButton()

   // Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System    
        
   // Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1)
   groupBox1.Controls.Add(radioButton2)
        
   // Add the GroupBox to the Form.
    Controls.Add(groupBox1)
}

必要条件

名前空間: System.Windows.Forms

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)

参照

GroupBox メンバ | System.Windows.Forms 名前空間 | RadioButton | ControlStyles.Selectable