TCheckBox: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TCheckBox
| Old | New | Line | |
|---|---|---|---|
| 1 | + | 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. | |
| 2 | + | ||
| 3 | + | <figure> | |
| 4 | + | <img src="TCheckBox-milk-sugar.png" title="TCheckBox-milk-sugar.png" /> | |
| 5 | + | <figcaption>TCheckBox-milk-sugar.png</figcaption> | |
| 6 | + | </figure> | |
| 7 | + | ||
| 8 | + | ## Usage | |
| 9 | + | ||
| 10 | + | To use a [[doc:lcl/stdctrls/tcheckbox.html|TCheckBox]] on a form | |
| 11 | + | ||
| 12 | + | 1. Click on the TCheckBox control on the standard toolbar. | |
| 13 | + | 2. Click on the form, the checkbox is placed on the form. | |
| 14 | + | 3. Go to the Object Inspector. On the **Properties** tab, on the **Name** property, change the name of the control to something appropriate. | |
| 15 | + | 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. | |
| 16 | + | 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. | |
| 17 | + | 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**. | |
| 18 | + | 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. | |
| 19 | + | 8. To change a checkbox's value in code, set its **checked** property to the value to indicate if the checkbox is checked or unchecked, respectively. | |
| 20 | + | ||
| 21 | + | ## See also | |
| 22 | + | ||
| 23 | + | - [[doc:lcl/stdctrls/tcheckbox.html|TCheckBox doc]] | |
| 24 | + | - [[TCheckGroup]] | |
| 25 | + | - [[TCheckListBox]] | |
| 26 | + | - [[TLabel]] | |
| 27 | + | ||
| 28 | + | --- | |
| 29 | + | *From the Free Pascal wiki, page "TCheckBox", as it stood on 2017-01-21 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
