Difference between revisions of "TCheckBox"
From Lazarus wiki
Jump to navigationJump to search (→Use) |
(→Use) |
||
Line 13: | Line 13: | ||
# 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 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. | # 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 value | + | # to change a checkbox's value in code, set its '''checked''' property to the value {{TF}} to indicate if the checkbox is checked or unchecked, respectively. |
Revision as of 20:09, 8 April 2013
>> 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.
Introduction
The Tcheckbox control is the standard checkbox having two states, checked and unchecked.
Use
To use a checkbox on a form
- Click on the Tcheckbox control on the standard toolbar.
- Click on the form and without letting go of the mouse, draw a box approximately where you want the checkbox to appear. It will have grab handles around it, so you can drag the component where you want it on the form.
- Go to the Property 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.
This is a stub page until completed
Return To: LCL Components | — Previous: TToggleBox | Next: TRadioButton |