CheckBox.ThreeState Propiedad

Definición

Obtiene o establece un valor que indica si la casilla CheckBox podrá tener tres estados de verificación en lugar de dos.

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

Valor de propiedad

true si el control CheckBox puede mostrar tres estados de activación; en cualquier otro caso, false. El valor predeterminado es false.

Ejemplos

En el ejemplo de código siguiente se muestran los valores de tres propiedades de una etiqueta. La ThreeState propiedad alterna entre true y false con clics alternativos del control y las CheckAlign alternativas entre los MiddleRight valores y MiddleLeft de System.Drawing.ContentAlignment. En este ejemplo se muestra cómo cambian los valores de propiedad a medida que cambia la ThreeState propiedad y se comprueba el control. Este código requiere que se haya creado una CheckBoxLabel instancia de y Button en un formulario y que la etiqueta sea lo suficientemente grande como para mostrar tres líneas de texto, así como una referencia al System.Drawing espacio de nombres. Se debe llamar a este código en el Click controlador de eventos del control .

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

Comentarios

Si la ThreeState propiedad se establece falseen , el valor de la CheckState propiedad solo se puede establecer en el valor de System.Windows.Forms.CheckState en el código y no mediante la Indeterminate interacción del usuario.

Se aplica a