CheckBox.CheckState Özellik

Tanım

durumunu CheckBoxalır veya ayarlar.

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

Özellik Değeri

Numaralandırma değerlerinden CheckState biri. Unchecked varsayılan değerdir.

Öznitelikler

Özel durumlar

Atanan değer numaralandırma değerlerinden CheckState biri değil.

Örnekler

Aşağıdaki kod örneği, bir etiketteki üç özelliğin değerlerini görüntüler. özelliği, ThreeState denetimin CheckAlign alternatif tıklamalarıyla ve arasında, falsetrue ve MiddleLeft değerleri arasında MiddleRight da alternatif olarak System.Drawing.ContentAlignmentdeğişir. Bu örnekte, özellik değiştikçe ve denetim denetlendikçe ThreeState özellik değerlerinin nasıl değiştiği gösterilir. Bu örnek, bir CheckBoxLabelButton ve tüm örneğinin bir formda örneğini oluşturmasını ve etiketin üç metin satırı ve ad alanına başvuru System.Drawing görüntüleyecek kadar büyük olmasını gerektirir. Bu kod denetimin Click olay işleyicisinde çağrılmalıdır.

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

Açıklamalar

ThreeState Özelliği olarak falseCheckState ayarlanırsa, özellik değeri kullanıcı etkileşimi tarafından değil yalnızca kodda olarak ayarlanabilirCheckState.Indeterminate.

Aşağıdaki tabloda, denetimin ve stil denetimi için farklı durumlarındaki durumu CheckBox.AppearanceNormal açıklanmaktadırSystem.Windows.Forms.Appearance.ButtonCheckBox

Checkstate Görünüm.Normal Görünüm.Düğme
Checked onay CheckBox işareti görüntüler. Denetim batık görünür.
Unchecked CheckBox boş. Denetim yükseltilmiş olarak görünür.
Indeterminate onay CheckBox işareti görüntüler ve gölgelidir. Denetim düz görünür.

Şunlara uygulanır

Ayrıca bkz.