TCheckBox

Deutsch (de) English (en) suomi (fi)

A TCheckBox is a component that provides a label with a box which can contain a check mark. The TCheckbox control is the standard checkbox. It is available fron the Standard tab of the Component Palette. When the TCheckBox is checked (☑) then checked property is True otherwise False. If property AllowGrayed is set to False (default value), the check box has only two possible states (property State): cbChecked and cbUnchecked. If AllowGrayed is set to True, the check box has three possible states: cbChecked, cbUnchecked and cbGrayed.

Usage

To use a TCheckBox on a form

1. Click on the TCheckBox control on the standard toolbar.
2. Click on the form, the checkbox is placed on the form.
3. Go to the Object Inspector. On the Properties tab, on the Name property, change the name of the control to something appropriate.
4. In the property checked, if the default state of the checkbox is not unchecked, double click on the value to flip it from false to true.
5. There will be a label appearing to the right of this checkbox, usually set to something like its name, e.g. Checkbox1. To change the label displayed, go to the caption property, type in the desired text and press enter.
6. If for some reason you want the label to appear to the left of the checkbox, go to the property BidiMode and change the value of this property to bdLeftToRight. To restore it to the standard display, change this value to bdRightToLeft.
7. If the checkbox simply stores a value, you're done. If you need to have the checkbox do something when it's clicked, you need to add an event. To do that, click on the Events tab, click on the property OnClick, then click on the button with three dots. You'll be taken to the code window and the handler for the OnClick event will be created. You can enter the code to be executed if this event occurs.
8. To change a checkbox's value in code, set its checked property to the value True or False to indicate if the checkbox is checked or unchecked, respectively.