Contents
CheckBox  Sample Help

Sample Description: CheckBox

Points of Interest

Referencing a Font

Changing Font Attributes

Control

CheckBox

For Help on Help, Press F1


CheckBox

The purpose of this sample is to give you a basic understanding of the checkbox control and some of its main properties.

The CheckBox is composed of a small box, which can be checked or unchecked, with some text beside it. This control is used to present the user with an on/off type choice that has only two possible settings. Clicking in the box once causes an X to appear. Clicking it again removes the X causing the box to be empty. Each time the box is clicked, it selects or deselects the control.

To determine whether or not a user has selected the control, you can check its Value property in code. Operation of each CheckBox on a Form is independent of all other CheckBoxes; changing the status of one CheckBox does not affect other CheckBoxes.

The program can set or read the current status with the Value property. This property has two possible settings. A setting of 0 indicates the box is currently empty. A setting of 1 means the box is currently checked. In addition, a CheckBox control may be disabled or "grayed." This can be done by setting the Enabled property to False.

The text that goes with the CheckBox can be set with the Caption property. The default font may be changed by referencing a Font object. The CheckBox Click event is triggered by clicking on the control or pressing the spacebar while the CheckBox has input focus.

In this sample, four CheckBoxes are programmed to change the properties of a font object that is referenced by a Label on the sample form. Clicking each of the CheckBoxes toggles the setting of the corresponding font property.


Referencing a Font

In this sample, a Label named lblWelcome was added to the top of the form. A font object named FontWelcome was embedded in the Property Editor. The Font property of lblWelcome references FontWelcome as its font source. This means that the lblWelcome control will display what ever font properties are defined by the FontWelcome object.

Referencing a font is a matter of clicking on the control's Font reference property (>>Font) and then entering the name of the font reference in the Property Editor. Of course you must click the X button to record the reference.


Changing Font Attributes

In this sample, four CheckBoxes are used to toggle various font properties of the FontWelcome object. As these properties are changed, the font displayed in the lblWelcome control is automatically updated. The fonts update because the lblWelcome control references the FontWelcome object as its font source.