From Xojo Documentation

Revision as of 20:07, 2 August 2021 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Class (inherits from DesktopUIControl)

New in 2021r3

The standard checkbox control used by desktop apps.

For web apps, see WebCheckBox.
Bold FontSize Underline
Caption FontUnit Value
FontName Italic VisualState


Checkboxes can have three states:

CheckBox VisualStates.png

The Caption text does not wrap.

Sample Code

The following code in the DesktopCheckBox's ValueChanged event handler checks the value of the CheckBox:

If CheckBox1.Value Then
TextField1.Value = "True"
TextField1.Value = "False"
End If

Because DesktopCheckbox is a three-state control, you can use the VisualState property to get and set its value. The DesktopCheckBox.VisualStates Enumeration is designed to get and set the values.

The following code sets the VisualState property of a DesktopCheckBox to Indeterminate.

CheckBox1.VisualState = CheckBox.VisualStates.Indeterminate

Because VisualState is an Enumeration, you cannot use the corresponding Integer value for comparison. The following code shows how to use State in a Select Case statement:

Select Case CheckBox1.VisualState
Case CheckBox.VisualStates.Unchecked
// The CheckBox is unchecked

Case CheckBox.VisualStates.Checked
// The CheckBox is checked

Case CheckBox.VisualStates.Indeterminate
// The CheckBox state is indeterminate

End Select

See the entries for VisualState and Value for additional examples of setting and getting DesktopCheckBox values. See also the DesktopCheckBox.VisualStates Enumeration.

See Also

DesktopRadioGroup control