System.Windows.Forms.CheckBox Class

Represents a Windows System.Windows.Forms.CheckBox.

See Also: CheckBox Members

Syntax

[System.ComponentModel.ToolboxItem("System.Windows.Forms.Design.AutoSizeToolboxItem,System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.DefaultBindingProperty("CheckState")]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.ComponentModel.DefaultEvent("CheckedChanged")]
[System.ComponentModel.DefaultProperty("Checked")]
public class CheckBox : ButtonBase

Remarks

Use a System.Windows.Forms.CheckBox to give the user an option, such as true/false or yes/no. The System.Windows.Forms.CheckBox control can display an image or text or both.

System.Windows.Forms.CheckBox and System.Windows.Forms.RadioButton controls have a similar function: they allow the user to choose from a list of options. System.Windows.Forms.CheckBox controls let the user pick a combination of options. In contrast, System.Windows.Forms.RadioButton controls allow a user to choose from mutually exclusive options.

The CheckBox.Appearance property determines whether the System.Windows.Forms.CheckBox appears as a typical System.Windows.Forms.CheckBox or as a button.

The CheckBox.ThreeState property determines whether the control supports two or three states. Use the CheckBox.Checked property to get or set the value of a two-state System.Windows.Forms.CheckBox control and use the CheckBox.CheckState property to get or set the value of a three-state System.Windows.Forms.CheckBox control.

Note:

If the CheckBox.ThreeState property is set to true, the CheckBox.Checked property will return true for either a checked or indeterminate state.

The ButtonBase.FlatStyle property determines the style and appearance of the control. If the ButtonBase.FlatStyle property is set to FlatStyle.System, the user's operating system determines the appearance of the control.

Note:

When the ButtonBase.FlatStyle property is set to FlatStyle.System, the CheckBox.CheckAlign property is ignored and the control is displayed using the System.Drawing.ContentAlignment.MiddleLeft or System.Drawing.ContentAlignment.MiddleRight alignment. If the CheckBox.CheckAlign property is set to one of the right alignments, the control is displayed using the System.Drawing.ContentAlignment.MiddleRight alignment; otherwise, it is displayed using the System.Drawing.ContentAlignment.MiddleLeft alignment.

The following describes an indeterminate state: You have a System.Windows.Forms.CheckBox that determines if the selected text in a System.Windows.Forms.RichTextBox is bold. When you select text you can click the System.Windows.Forms.CheckBox to bold the selection. Likewise, when you select some text, the System.Windows.Forms.CheckBox displays whether the selected text is bold. If your selected text contains text that is bold and normal, the System.Windows.Forms.CheckBox will have an indeterminate state.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0