Home > Articles > Programming > User Interface (UI)

This chapter is from the book

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.8Figure 3.8 An application that showcases CheckBox controls running on the Pocket PC 2002 emulator.

  • + Share This
  • 🔖 Save To Your Account