Gets or sets a value indicating whether the check box is checked.
[Visual Basic] Public Property Checked As Boolean [C#] public bool Checked {get; set;} [C++] public: __property bool get_Checked(); public: __property void set_Checked(bool); [JScript] public function get Checked() : Boolean; public function set Checked(Boolean);
true if the checkbox is checked; otherwise, false. The default value is false.
Note If the ThreeState property is set to true, the Checked property will return true for either checked or indeterminately checked values.
When the value is true the check box portion of the control displays a check mark. If the Appearance property is set to Button the control will appear sunken when Checked is true.
The following code example will display the values of four properties and displays them in a label. The ThreeState property alternates between true and false with every click of the button and the CheckAlign alternates between MiddleLeft and MiddleRight. This example will allow you to see how the property values change as the ThreeState property changes and the button is checked. This code assumes a CheckBox, Label and Button have all been instantiated on a form and the lanbel should be large enough to display four lines of text..
[Visual Basic]
Private MySub() ' Concatenate the property values together on four lines. Label1.Text = "ThreeState: " & CheckBox1.ThreeState & vbCrLf & _ "Checked: " & CheckBox1.Checked & vbCrLf & _ "CheckState: " & CheckBox1.CheckState & vbCrLf & _ "AccessibleState: " & CheckBox1.AccessibleState ' Change the ThreeState and CheckAlign properties on every other click. If CheckBox1.ThreeState = False Then CheckBox1.ThreeState = True CheckBox1.CheckAlign = System.Drawing.ContentAlignment.MiddleRight Else CheckBox1.ThreeState = False CheckBox1.CheckAlign = System.Drawing.ContentAlignment.MiddleLeft End If End Sub
CheckBox Class | CheckBox Members | System.WinForms Namespace | ThreeState | CheckState