User Tools

Site Tools


16.17 CheckBox

The next two chapters describe the two components CheckBox and RadioButton. Each component has its own specific function:

  • A CheckBox is a component for activating/deactivating an option.
  • A RadioButton, on the other hand, is a component for selecting an option from a group of at least 2 options. Each option is represented by a radio button of the group and only one option can be selected.


Figure 16.17.1: Three CheckBoxes and a group of three RadioButtons

  • For example, for the scanner → figure 16.17.1, you set with three checkboxes 8 completely independent of each other existing variants - from all three options ☑☑☑ set to no option ⎕⎕⎕ set.
  • For the scan mode, you can use three RadioButtons to select only one mode from three possible modes, since all three RadioButtons belong to the same group and only one RadioButton can be set to active.

Control element CheckBox

The control element CheckBox (gb.qt4) implements a CheckBox that can be selected or not. If the tristate property is defined, then the CheckBox state is interpreted as “state unknown (not defined)” or “should not be changed”.

AutoresizeBooleanFalseDetermines the value or determines whether the size of the CheckBox automatically adapts to the descriptive text.
TextStringNullDetermines the text or specifies the text to be displayed on the CheckBox as caption.
CaptionStringNullSynonym for Text
TristateBooleanFalseDetermines or determines whether the CheckBox has a third state.
ValueInteger0Determines or determines which value the CheckBox has.

Table 16.17.1: Properties CheckBox

The property CheckBox.Value can have three values -1, 0 or 1, which applies to the state in connection with the defined CheckBox constants and the .Tristate property:

Not selected0CheckBox.False
Indeterminate1CheckBox.None ( + CheckBox.Tristate = True)

Table 16.17.2: Values of the property CheckBox.Value

The click event is triggered when the user clicks on the checkbox and the state of the checkbox changes. If CheckBox.Tristate = False, then the state changes alternatively. Otherwise, the order is:⎕ → ⊟ → ☑ .You can quickly convince yourself of this if you set the CheckBox.Tristate property to True or False for a CheckBox and use this event handling routine:

Public Sub CheckBox1_Click()
  Select CheckBox1.Value
    Case -1
      Print "CheckBox checked" 	    ' State: selected
    Case 0
      Print "CheckBox unchecked" 	    ' State: not selected
    Case CheckBox1.None
      Print "CheckBox indeterminate" ' State: indifferent
  End Select
End ' CheckBox1_Click()

This is remarkable: The complete source code (trunk/) of gambas show an application of CheckBox.Tristate only in the supplied example GameOfLife.




The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k16/k16.17/start.txt · Last modified: 29.09.2023 by emma

Page Tools