System.Windows.Forms


.NET Framework クラス ライブラリ
GroupBox クラス

キャプション付きコントロールまたはキャプションなしコントロールのグループの周りにフレームを表示する Windows コントロールを表します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

構文

Visual Basic (宣言)
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class GroupBox
    Inherits Control
Visual Basic (使用法)
Dim instance As GroupBox
C#
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class GroupBox : Control
C++
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class GroupBox : public Control
J#
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class GroupBox extends Control
JScript
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class GroupBox extends Control
解説

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

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

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

メモメモ

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

GroupBox には、スクロール バーを表示できません。スクロール バーを表示できる GroupBox のようなコントロールが必要な場合には、Panel コントロールのトピックを参照してください。

使用例

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

Visual Basic
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 
C#
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
参照

タグ :


Page view tracker