Gets or sets a value indicating whether the CheckBox will allow three check states rather than two.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
'Declaration Public Property ThreeState As Boolean 'Usage Dim instance As CheckBox Dim value As Boolean value = instance.ThreeState instance.ThreeState = value
The following code example displays the values of three properties in a label. The 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 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.
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
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.