- Investigating Unsupported Controls in the .NET Compact Framework
- Investigating Unsupported System.Windows.Forms Functionality in the .NET Compact Framework
- Working with the Visual Studio .NET Form Designer
- Understanding the Different Windows Forms Target Platforms
- Working with the Form Control
- Programming the Button Control
- Using the TextBox Control
- Using the Label Control
- Working with RadioButton Controls
- Using the CheckBox Control
- Using the ComboBox Control
- Using the ListBox Control
- Using the NumericUpDown Control
- Using the DomainUpDown Control
- Programming the ProgressBar Control
- Using the StatusBar Control
- Using the TrackBar Control
- Using the ToolBar Control
- Adding Menus with the MainMenu Control
- Using a ContextMenu Control in an Application
- Using the Timer Control
- Using the OpenFileDialog and SaveFileDialog Controls
- Using the Panel Control
- Using the HScrollBar and VScrollBar Controls
- Using the ImageList Control
- Using the PictureBox Control
- Using the ListView Control
- Using the TabControl Control
- Using the TreeView Control
- Working with the DataGrid Control
- In Brief
Using the CheckBox Control
The CheckBox control is similar to the RadioButton control in that it presents a list of choices to the user. The difference is that multiple CheckBox controls can be selected at once, while RadioButton controls are mutually exclusive. The CheckBox control is usually a GUI for a Boolean value or expression.
The CheckBox control provides the CheckState property, which determines whether the CheckBox is checked. The CheckState property is actually an enumeration, the CheckState enumeration. Its members are Unchecked, Checked, and Indeterminate. Unchecked and Check are self-explanatory, but the Indeterminate member warrants explanation. The Indeterminate state can be used only when the CheckBox control's ThreeState property is set to true. When the CheckState is Indeterminate and the ThreeState property is true, the control is grayed out but still checked. This signifies that the check state cannot be determined. The control will not respond to user clicks as long as the AutoCheck property is false. When the AutoCheck property is set to true, a click with the stylus will enable the control.
The Apples.exe application is another simple survey that attempts to determine what type of apples the user likes. The topmost CheckBox control has the caption "I like apples." The other CheckBox controls are labeled with different types of apples and are in an indeterminate state until the CheckBox labeled "I like apples" is checked; only then can the user check which apples he or she actually likes. If the user does not like apples, then there is no reason for the other CheckBox controls to be available. Figure 3.8 shows the application running in the Pocket PC emulator. The full code for this application can be found in the source code of this book.
Figure 3.8 An application that showcases CheckBox controls running on the Pocket PC 2002 emulator.