From Xojo Documentation

(Redirected from Checkbox)

Class (inherits from RectControl)

The standard checkbox control used by desktop apps.

For web apps, see WebCheckBox.
Action DropObject MouseExit
Close GotFocus MouseMove
ConstructContextualMenu KeyDown MouseUp
ContextualMenuAction KeyUp MouseWheel
DragEnter LostFocus Open
DragExit MouseDown
DragOver MouseEnter
Active fa-lock-32.png LockBottom TabStop
AutoDeactivate LockLeft TextFont
Bold LockRight TextSize
Caption LockTop TextUnit
DataField MouseCursor Top
DataSource MouseX fa-lock-32.png Transparent
Enabled MouseY fa-lock-32.png TrueWindow fa-lock-32.png
Handle fa-lock-32.png Name Underline
Height PanelIndex Value
HelpTag Parent Visible
Index fa-lock-32.png Scope fa-lock-32.png Width
Italic State Window fa-lock-32.png
Left TabIndex
AcceptFileDrop Close RefreshRect
AcceptPictureDrop DrawInto SetBoolean
AcceptRawDataDrop Invalidate SetFocus
AcceptTextDrop Refresh


Checkboxes can have three states: CheckBox States.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.Text = "True"
TextField1.Text = "False"
End If

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

The following code sets the State property of a Checkbox to Indeterminate.

Checkbox1.State = Checkbox.CheckedStates.Indeterminate

Because State 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.State
Case CheckBox.CheckedStates.Unchecked
// The CheckBox is unchecked

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

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

End Select

See the entries for State and Value for additional examples of setting and getting Checkbox values. See also the CheckedStates Enumeration.

See Also

RadioButton control