NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

CheckBox.CheckState

Gets or sets a value indicating whether the check box is checked.

[Visual Basic]
Public Property CheckState As CheckState
[C#]
public CheckState CheckState {get; set;}
[C++]
public: __property CheckState get_CheckState();
public: __property void set_CheckState(CheckState);
[JScript]
public function get CheckState() : CheckState;
public function set CheckState(CheckState);

Property Value

One of the System.WinForms.CheckStateEnum values. The default value is Unchecked.

Exceptions

Exception Type Condition
InvalidEnumArgumentException The value assigned is not one of the System.WinForms.CheckStateEnum values.

Remarks

Note   If the ThreeState property is set to false, then the CheckState property will not return the value of Indeterminate.

When the value is Checked 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 the value is Indeterminate the check box portion of the control displays a check mark and the check box is shaded. If the Appearance property is set to Button the control will appear flat.

When the value is Unchecked the check box portion of the control is empty. If the Appearance property is set to Button the control will appear raised.

Example [Visual Basic]

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

See Also

CheckBox Class | CheckBox Members | System.WinForms Namespace | Checked | ThreeState