CheckBoxes
Xojo Version 2021 r3.1
Description:
Checkboxes are used when you want to allow the user to select multiple options from a group of options. Checkboxes can also be used as a "toggle" to turn an option on or off. Checkboxes should always be placed inside of a Group Box.
Library Location:
Checkboxes are found in the Pickers category in the Xojo Library
Naming Conventions:
The prefix for a Checkbox is chk
Adding a Checkbox to your form:
- Place a Group Box onto your Form and give it a name (Remember to follow our naming conventions)
- Place a Checkbox inside of the Group Box
- In the Inspector, give the Checkbox a name (following our naming conventions) and add a caption
- Repeat this process until you have added all the Checkboxes you require
Accessing the Value a Checkbox
The Value property tells us if a checkbox is selected or not by returning a Boolean (True/False).
- If the Checkbox is selected, the Value property is True.
- If the Checkbox is not selected, the Value property is False.
By default, the value property is always set to false. You can change this in the Inspector as needed.
Using a Single If Statement to Determine the Value of a Checkbox
We can use an Single If Statement to test the value property of a Checkbox.
If (chkVanilla.Value = "True") then
lstOut.AddRow("You added Vanilla Syrup to Your Coffee")
syrups = syrups + 1.25
End If