This documentation is archived and is not being maintained.

CheckBox::ThreeState Property

Gets or sets a value indicating whether the CheckBox will allow three check states rather than two.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

property bool ThreeState {
	bool get ();
	void set (bool value);

Property Value

Type: System::Boolean
true if the CheckBox is able to display three check states; otherwise, false. The default value is false.

If the ThreeState property is set to false, the CheckState property value can only be set to the Indeterminate value of System.Windows.Forms::CheckState in code and not by user interaction.

The following code example displays the values of three properties in a label. The ThreeState property alternates between true and false with alternating clicks of the control and the CheckAlign alternates between the MiddleRight and MiddleLeft values of System.Drawing::ContentAlignment. This example shows how the property values change as the ThreeState property changes and the control is checked. This code requires that a CheckBox, Label and Button have all been instantiated on a form and that the label is large enough to display three lines of text, as well as a reference to the System.Drawing namespace. This code should be called in the Click event handler of the control.

   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;
         checkBox1->ThreeState = false;
         checkBox1->CheckAlign = ContentAlignment::MiddleLeft;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0