11.10. Adding Checkboxes to a Form
You want to add checkboxes to your form.
Use checkbox UI components.
You should use checkboxes in situations in which you want a user to be able to select multiple options from a list, but you do not wish to use a list box. Or, alternatively, you should use a checkbox in any situation that calls for a simple yes/no or true/false answer. Checkboxes function similarly to radio buttons, except for a few important distinctions:
You cannot set a data value for a checkbox. Checkboxes have only two possible values:
Checkboxes do not have a natively available group as radio buttons do.
Multiple checkboxes should not be used for mutually exclusive choices.
You can set the label of a checkbox with the
) method, and you can set the placement of the label
(right or left) using the
method, just as with radio buttons.
The fact that checkboxes don’t provide native support for grouping, as radio buttons do, is not necessarily a problem. However, by adding grouping functionality to checkboxes (and coding the checkbox group class to inherit from the radio button group class), you can easily leverage the resizing and positioning code from Recipe 11.7 and Recipe 11.8 for radio button groups to work with checkboxes.
You can create a custom checkbox group class as follows:
FCheckBoxGroupClassto inherit from