キャプション付きコントロールまたはキャプションなしコントロールのグループの周りにフレームを表示する Windows コントロールを表します。
名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class GroupBox
Inherits Control
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class GroupBox : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class GroupBox : public Control
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class GroupBox extends Control
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class GroupBox extends Control
GroupBox はキャプション付きコントロールまたはキャプションなしコントロールのグループの周りにフレームを表示します。GroupBox を使用して、フォーム上のコントロールのコレクションを論理的にグループ化します。グループ ボックスは、コントロールのグループを定義するために使用できるコンテナ コントロールです。
グループ ボックスは、一般的に RadioButton コントロールの論理グループを格納するために使用されます。2 つのグループ ボックスのそれぞれに複数のオプション ボタンがある場合、各ボタン グループで一度に選択できるボタンは 1 つだけで、設定されるオプション値もそれぞれ 1 つです。
Controls プロパティの Add メソッドを使用して、コントロールを GroupBox に追加できます。
GroupBox には、スクロール バーを表示できません。スクロール バーを表示できる GroupBox のようなコントロールが必要な場合には、Panel コントロールのトピックを参照してください。
GroupBox と 2 つの RadioButton コントロールをインスタンス化および作成するコード例を次に示します。オプション ボタンはグループ ボックスに追加され、グループ ボックスは Form に追加されます。
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
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);
}
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.GroupBox
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
.NET Framework
サポート対象 : 2.0、1.1、1.0