CheckBox

From Xojo Documentation

Class (inherits from RectControl)

The standard checkbox control used by desktop apps.

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

Notes

Checkboxes can have three states: CheckBox States.png

fa-info-circle-32.png
The Caption text does not wrap.

Sample Code

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

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

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

The following code sets the VisualState property of a CheckBox 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 CheckBox values. See also the CheckBox.VisualStates Enumeration.

See Also

RadioButton control