Using Checkboxes



Sample code:
Display file source:                 PUISAMPLES/QDDSSRC(CHECK001D)
RPGLE source:                      PUISAMPLES/QRPGLESRC(CHECK001R)

A checkbox is an input widget that has two states: checked and unchecked.  To create a checkbox in your application, drag the widget onto the canvas, and then double-click the label adjacent to the box to edit its text or simply modify the label property in the Properties Window.

Next, you should bind the value property to an RPG variable that will be used to initialize and retrieve the state of the checkbox.  It is common to declare this variable as an indicator or a character data type with a length of 1 in the Binding Dialog.

Then, you should specify the checked value and unchecked value properties.  For example, use Y for checked and N for unchecked, or 1 for checked and 0 for unchecked.

In your program, use the RPG variable bound to the value property to see if the user checked or unchecked the box.  To initialize the checkbox to a checked state, make sure to fill the RPG variable bound to the value property with a literal equivalent to the checked value property before showing the screen.