CheckBox.CheckState 속성

정의

CheckBox의 상태를 가져오거나 설정합니다.

public:
 property System::Windows::Forms::CheckState CheckState { System::Windows::Forms::CheckState get(); void set(System::Windows::Forms::CheckState value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.Forms.CheckState CheckState { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.CheckState : System.Windows.Forms.CheckState with get, set
Public Property CheckState As CheckState

속성 값

CheckState 열거형 값 중 하나입니다. 기본값은 Unchecked입니다.

특성

예외

할당된 값이 CheckState 열거형 값이 아닌 경우

예제

다음 코드 예제에서는 레이블에 세 속성의 값을 표시 합니다. ThreeState 합니다 속성 사이 true 대체 하 false 고 번갈아 클릭을 사용 하 고는 컨트롤 및 CheckAlign 의 값을 System.Drawing.ContentAlignment대체 합니다 MiddleRightMiddleLeft. 이 예제에서는 속성이 변경되고 컨트롤이 ThreeState 확인되면 속성 값이 어떻게 변경되는지 보여 집니다. 이 예제에서는 및 LabelButtonCheckBox양식에서 모두 인스턴스화되고 레이블이 세 줄의 텍스트와 네임스페이스에 대한 참조를 표시할 수 있을 만큼 커야 합니다System.Drawing. 이 코드는 컨트롤의 Click 이벤트 처리기에서 호출되어야 합니다.

private:
   void AdjustMyCheckBoxProperties()
   {
      // Concatenate the property values together on three lines.
      label1->Text = String::Format( "ThreeState: {0}\nChecked: {1}\nCheckState: {2}",
         checkBox1->ThreeState, checkBox1->Checked, checkBox1->CheckState );
      
      // Change the ThreeState and CheckAlign properties on every other click.
      if ( !checkBox1->ThreeState )
      {
         checkBox1->ThreeState = true;
         checkBox1->CheckAlign = ContentAlignment::MiddleRight;
      }
      else
      {
         checkBox1->ThreeState = false;
         checkBox1->CheckAlign = ContentAlignment::MiddleLeft;
      }
   }
private void AdjustMyCheckBoxProperties()
 {
    // Change the ThreeState and CheckAlign properties on every other click.
    if (!checkBox1.ThreeState)
    {
       checkBox1.ThreeState = true;
       checkBox1.CheckAlign = ContentAlignment.MiddleRight;
    }
    else
    {
       checkBox1.ThreeState = false;
       checkBox1.CheckAlign = ContentAlignment.MiddleLeft;
    }

    // Concatenate the property values together on three lines.
    label1.Text = "ThreeState: " + checkBox1.ThreeState.ToString() + "\n" +
                  "Checked: " + checkBox1.Checked.ToString() + "\n" +
                  "CheckState: " + checkBox1.CheckState.ToString(); 
 }
Private Sub AdjustMyCheckBoxProperties()

    ' Change the ThreeState and CheckAlign properties on every other click.
    If Not checkBox1.ThreeState Then
        checkBox1.ThreeState = True
        checkBox1.CheckAlign = ContentAlignment.MiddleRight
    Else
        checkBox1.ThreeState = False
        checkBox1.CheckAlign = ContentAlignment.MiddleLeft
    End If

    ' Concatenate the property values together on three lines.
    label1.Text = "ThreeState: " & checkBox1.ThreeState.ToString() & ControlChars.Cr & _
        "Checked: " & checkBox1.Checked.ToString() & ControlChars.Cr & _
        "CheckState: " & checkBox1.CheckState.ToString()

End Sub

설명

속성이 로 ThreeStateCheckState 설정된 false경우 속성 값은 사용자 상호 작용이 아닌 코드에서만 로 CheckState.Indeterminate 설정할 수 있습니다.

다음 표에서는 System.Windows.Forms.AppearanceButton 스타일 컨트롤 에 CheckBox 대한 다양한 상태의 컨트롤CheckBox.Appearance에 대한 를 Normal 설명합니다.

CheckState Appearance.Normal Appearance.Button
Checked CheckBox 검사 표시를 표시합니다. 컨트롤이 침몰한 것처럼 보입니다.
Unchecked CheckBox가 비어 있는 경우 컨트롤이 발생한 것처럼 보입니다.
Indeterminate CheckBox 검사 표시를 표시하고 음영 처리됩니다. 컨트롤이 평면으로 표시됩니다.

적용 대상

추가 정보