CheckBox.ThreeState 속성

정의

CheckBox가 두 가지가 아닌 세 가지의 선택 상태를 허용하는지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool ThreeState { bool get(); void set(bool value); };
public bool ThreeState { get; set; }
member this.ThreeState : bool with get, set
Public Property ThreeState As Boolean

속성 값

CheckBox가 세 가지의 선택 상태를 표시할 수 있으면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예제

다음 코드 예제에서는 레이블에 세 속성의 값을 표시 합니다. ThreeState 속성은 와 truefalse 를 번갈아 가며 컨트롤을 번갈아 클릭하고 의 값과 System.Drawing.ContentAlignmentCheckAlignMiddleLeft 를 번갈아 가며 대체합니다.MiddleRight 이 예제에서는 속성이 변경되고 컨트롤이 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경우 속성 값은 사용자 상호 작용이 Indeterminate 아닌 코드의 System.Windows.Forms.CheckState 값으로만 설정할 수 있습니다.

적용 대상