다음을 통해 공유


GroupBox 클래스

컨트롤의 그룹 주위에 프레임을 표시하며 캡션을 넣을 수도 있는 Windows 컨트롤을 나타냅니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class GroupBox
    Inherits Control
‘사용 방법
Dim instance As GroupBox
[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를 사용하여 폼에 있는 컨트롤 컬렉션을 논리적으로 그룹화합니다. 그룹 상자는 컨트롤 그룹을 정의하는 데 사용할 수 있는 Container 컨트롤입니다.

그룹 상자의 일반적인 용도는 RadioButton 컨트롤의 논리적 그룹을 포함하는 것입니다. 각각 여러 옵션 단추(라디오 단추라고도 함)를 포함하는 두 개의 그룹 상자가 있는 경우 두 단추 그룹은 함께 사용할 수 없으며 그룹마다 하나의 옵션 값이 설정됩니다.

Controls 속성의 Add 메서드를 사용하여 GroupBox에 컨트롤을 추가할 수 있습니다.

참고

GroupBox 컨트롤 내에 포함된 컨트롤만 선택되거나 포커스를 받을 수 있습니다. 전체 GroupBox 자체는 선택되거나 포커스를 받을 수 없습니다. 이 컨트롤이 FocusSelect 메서드에 응답하는 방법에 대한 자세한 내용은 CanFocus, CanSelect, Focused, ContainsFocus, Focus, Select 등의 Control 멤버를 참조하십시오.

GroupBox에서 스크롤 막대를 표시할 수 없습니다. 스크롤 막대를 포함할 수 있는 GroupBox와 유사한 컨트롤이 필요한 경우 Panel 컨트롤을 참조하십시오.

예제

다음 코드 예제에서는 GroupBox와 두 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
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);
}
 
private:
   void InitializeMyGroupBox()
   {
      // Create and initialize a GroupBox and two RadioButton controls.
      GroupBox^ groupBox1 = gcnew GroupBox;
      RadioButton^ radioButton1 = gcnew RadioButton;
      RadioButton^ radioButton2 = gcnew RadioButton;
      
      // Add the RadioButtons to the GroupBox.
      groupBox1->Controls->Add( radioButton1 );
      groupBox1->Controls->Add( radioButton2 );
      
      // Add the GroupBox to the Form.
      Controls->Add( groupBox1 );
   }
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.set_FlatStyle(FlatStyle.System);

    // Add the RadioButtons to the GroupBox.
    groupBox1.get_Controls().Add(radioButton1);
    groupBox1.get_Controls().Add(radioButton2);

    // Add the GroupBox to the Form.
    get_Controls().Add(groupBox1);
} //InitializeMyGroupBox
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.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에서 지원

참고 항목

참조

GroupBox 멤버
System.Windows.Forms 네임스페이스
Panel
RadioButton
ControlStyles.Selectable