다음을 통해 공유


CheckBox 클래스

Windows CheckBox를 나타냅니다.

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

구문

‘선언
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class CheckBox
    Inherits ButtonBase
‘사용 방법
Dim instance As CheckBox
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
public class CheckBox : ButtonBase
[ComVisibleAttribute(true)] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
public ref class CheckBox : public ButtonBase
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
public class CheckBox extends ButtonBase
ComVisibleAttribute(true) 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
public class CheckBox extends ButtonBase

설명

CheckBox를 사용하여 true/false 또는 yes/no와 같은 옵션을 선택할 수 있습니다. CheckBox 컨트롤에는 이미지, 텍스트 또는 이 둘을 모두 표시할 수 있습니다.

CheckBoxRadioButton 컨트롤의 기능은 옵션 목록에서 선택할 수 있다는 점에서 유사합니다. 그러나 CheckBox 컨트롤에서는 여러 옵션을 동시에 선택할 수 있지만 RadioButton 컨트롤에서는 동시에 선택할 수 없습니다.

Appearance 속성은 CheckBox를 일반적인 CheckBox로 표시할지 또는 단추 모양으로 표시할지 여부를 결정합니다.

ThreeState 속성은 컨트롤이 두 가지 상태를 지원할지 또는 세 가지 상태를 지원할지 여부를 결정합니다. Two-State CheckBox 컨트롤의 값을 가져오거나 설정하려면 Checked 속성을 사용하고 Three-State CheckBox 컨트롤의 값을 가져오거나 설정하려면 CheckState 속성을 사용합니다.

참고

ThreeState 속성을 true로 설정하면 Checked 속성은 선택한 상태 또는 결정되지 않은 상태에 대해 true를 반환합니다.

FlatStyle 속성은 컨트롤의 스타일 및 모양을 결정합니다. FlatStyle 속성을 FlatStyle.System으로 설정하면, 컨트롤의 모양은 사용자 시스템의 운영 체제에 의해서 결정됩니다.

참고

FlatStyle 속성이 FlatStyle.System으로 설정되면 CheckAlign 속성은 무시되고 ContentAlignment.MiddleLeft 또는 ContentAlignment.MiddleRight 맞춤을 사용하여 해당 컨트롤이 표시됩니다. CheckAlign 속성이 오른쪽 맞춤 중 하나로 설정되면 컨트롤은 ContentAlignment.MiddleRight 맞춤을 사용하여 표시되고, 그렇지 않으면 ContentAlignment.MiddleLeft 맞춤을 사용하여 표시됩니다.

다음에서는 결정되지 않은 상태를 설명합니다. 예를 들어, RichTextBox에서 선택한 텍스트를 굵게 표시할지 여부를 결정하는 CheckBox가 있습니다. 따라서 텍스트를 선택할 때 CheckBox를 클릭하여 선택한 텍스트를 굵게 표시할 수 있습니다. 또한 일부 텍스트를 선택할 경우 CheckBox는 선택한 텍스트가 굵게 표시되는지 여부를 표시합니다. 선택한 텍스트에 굵게 표시된 텍스트와 일반 텍스트가 포함된 경우 CheckBox는 결정되지 않은 상태로 표시됩니다.

예제

다음 코드 예제에서는 CheckBox를 만들고 초기화한 후 토글 단추 모양으로 나타낸 다음 AutoCheckfalse로 설정하여 Form에 추가합니다.

Public Sub InstantiateMyCheckBox()
    ' Create and initialize a CheckBox.   
    Dim checkBox1 As New CheckBox()
    
    ' Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button
    
    ' Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = False
    
    ' Add the check box control to the form.
    Controls.Add(checkBox1)
End Sub 'InstantiateMyCheckBox
public void InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 
public:
   void InstantiateMyCheckBox()
   {
      // Create and initialize a CheckBox.   
      CheckBox^ checkBox1 = gcnew CheckBox;
      
      // Make the check box control appear as a toggle button.
      checkBox1->Appearance = Appearance::Button;
      
      // Turn off the update of the display on the click of the control.
      checkBox1->AutoCheck = false;
      
      // Add the check box control to the form.
      this->Controls->Add( checkBox1 );
   }
public void InstantiateMyCheckBox()
{
    // Create and initialize a CheckBox.   
    CheckBox checkBox1 = new CheckBox();

    // Make the check box control appear as a toggle button.
    checkBox1.set_Appearance(Appearance.Button);

    // Turn off the update of the display on the click of the control.
    checkBox1.set_AutoCheck(false);

    // Add the check box control to the form.
    get_Controls().Add(checkBox1);
} //InstantiateMyCheckBox
public function InstantiateMyCheckBox()
 {
    // Create and initialize a CheckBox.   
    var checkBox1 : CheckBox = new CheckBox(); 
    
    // Make the check box control appear as a toggle button.
    checkBox1.Appearance = Appearance.Button;
 
    // Turn off the update of the display on the click of the control.
    checkBox1.AutoCheck = false;
 
    // Add the check box control to the form.
    Controls.Add(checkBox1);
 }
 

상속 계층 구조

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ButtonBase
          System.Windows.Forms.CheckBox

스레드로부터의 안전성

이 형식의 모든 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에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

CheckBox 멤버
System.Windows.Forms 네임스페이스
ButtonBase 클래스

기타 리소스

CheckBox 컨트롤(Windows Forms)