Grouping Options with Radio Buttons


 

Radio buttons present a set of two or more choices to the user. Unlike check boxes, however, radio buttons should normally work as part of a group; selecting one radio button immediately clears all the other buttons in the group. Defining a radio button group tells the user, "Here is a set of choices from which you can choose one and only one."

 

Creating Radio Button Groups

 

All of the option buttons placed directly on a form (that is, not in a frame or picture box) are by default unrelated. Any of the buttons can be off or on at the same time. If you want to relate the buttons and create a button group, specify the same value for the GroupId property of each buttons.

 

Normally, a GROUPBOX or other visual aid is employed to alert the user that the buttons are related and each is a part of a group. A user can select only one option button in the group when you group them together.

 

A simple way to set the GroupId property for a set of buttons is to first use the multiple selection capability of the designer to select all the required buttons. Then by simply setting the GroupId property once, all buttons will have the same value and will be related.

 

Selecting or Disabling Option Buttons

 

A radio button can be selected by:

  1. Clicking it at run time with the mouse.

  2. Tabbing to the option button group and then using the arrow keys to select an option button within the group.

  3. Assigning its Value property to True in code:

 

     SETPROP rdoChoice,Value=1

  1. Using a shortcut key specified in the tile property.

 

To make a button the default in an radio button group, set its Value property to one (1) at design time. It remains selected until a user selects a different radio button or code changes it.

 

To disable an radio button, set its Enabled property to False. When the program is run it will appear dimmed, meaning that it is unavailable.



PL/B IDE Studio Help Selecting Individual Options with Check Boxes Using DATALISTs and COMBOBOXes