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

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

특성

예외

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

예제

다음 코드 예제에서는 레이블에 세 가지 속성의 값을 표시합니다. 이 속성은 ThreeState 컨트롤의 번갈아 클릭과 해당 컨트롤 CheckAlign 의 값 System.Drawing.ContentAlignmentMiddleLeft MiddleRight 대체를 번갈 true false 아 사용합니다. 이 예제에서는 속성이 변경되고 컨트롤이 ThreeState 확인되면 속성 값이 변경되는 방법을 보여 집니다. 이 예제에서는 폼에서 모두 인스턴스화되었으며 네임스페이 CheckBoxLabel Button 스에 대한 참조뿐만 아니라 세 줄의 텍스트를 표시할 수 있을 만큼 레이블이 충분히 커야 합니다.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

설명

속성이 ThreeState 설정 false되면 사용자 상호 작용이 CheckState 아닌 코드에서만 속성 값을 설정할 CheckState.Indeterminate 수 있습니다.

다음 표에서는 컨트롤과 스타일 컨트롤의 CheckBox 다른 상태에 있는 컨트롤CheckBox.AppearanceNormal Button 대해 설명 System.Windows.Forms.Appearance 합니다.

CheckState Appearance.Normal Appearance.Button
Checked CheckBox 확인 표시가 표시됩니다. 컨트롤이 가라 뜨고 나타납니다.
Unchecked CheckBox가 비어 있는 경우 컨트롤이 발생한 것으로 나타납니다.
Indeterminate CheckBox 확인 표시가 표시되고 음영이 지정됩니다. 컨트롤이 평면으로 표시됩니다.

적용 대상

추가 정보