DesktopCheckBox

From Xojo Documentation

Class (inherits from DesktopUIControl)


New in 2021r3

The standard checkbox control used by desktop apps.

For web apps, see WebCheckBox.
Events
Closing FocusLost MouseMove
ConstructContextualMenu FocusReceived MouseUp
ContextualMenuItemSelected KeyDown MouseWheel
DragEnter KeyUp Opening
DragExit MouseDown ValueChanged
DragOver MouseEnter
DropObject MouseExit
Properties
Active fa-lock-32.png Index fa-lock-32.png Scope fa-lock-32.png
AllowAutoDeactivate Italic TabIndex
AllowTabStop Left Tooltip
Bold LockBottom Top
Caption LockLeft Transparent
Enabled LockRight Underline
FontName LockTop Value
FontSize MouseCursor Visible
FontUnit Name fa-lock-32.png VisualState
Handle fa-lock-32.png PanelIndex Width
Height Parent Window fa-lock-32.png
Methods
AcceptFileDrop AcceptTextDrop Refresh
AcceptPictureDrop Close SetFocus
AcceptRawDataDrop DrawInto
Enumerations
VisualStates

Notes

Checkboxes can have three states:

CheckBox VisualStates.png

fa-info-circle-32.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"
Else
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