TCheckBox
From Lazarus wiki
Jump to navigationJump to search
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
日本語 (ja) │
русский (ru) │
>> LCL Components >> TCheckBox
This page explains how to use the TCheckBox component. When I mention to click on something, unless I explicitly say to right-click, you always left-click on the item in question.
Description
A label with a box which can contain a check mark. The TCheckbox control is the standard checkbox having two states, checked and unchecked.
Usage
To use a TCheckBox on a form
- Click on the TCheckBox control on the standard toolbar.
- Click on the form, the checkbox is placed on the form.
- Go to the Object Inspector. On the Properties tab, on the Name property, change the name of the control to something appropriate.
- 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.
- 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.
- 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.
- 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.
- To change a checkbox's value in code, set its checked property to the value
True
orFalse
to indicate if the checkbox is checked or unchecked, respectively.
Return To: LCL Components | — Previous: TToggleBox | Next: TRadioButton |