In this section:
Radio buttons enable end users to make a single choice among a group of options. They are best used for a static group of options that change rarely or not at all (for example, gender, or day of the week).
The contents of the list are determined dynamically at run time by one of the following:
You define the radio button contents using the List Source dialog box, described in List Source Dialog Box. You define how to store the value returned from the radio buttons using the Binding the Selection Result dialog box, described in Binding the Selection Result Dialog Box.
Note: You must create a variable with the data type Stack of.
Caution: Do not bind SelectedItem to a data source stack that already contains data. This will replace the contents of the data source stack with the result of the selection.
If you want to set the value of a group of radio buttons dynamically, issue the following command
COMPUTE Formname.RadioButtonName.ListItems.FocIndex = n;
Is the name of the form on which the radio button control is placed.
Is the name of the radio button control.
Is the name of an internal data source stack that contains the values for the group of radio buttons.
You can also reset the values of all controls in a form to their initial values using the Winform Reset command. For more information, see How to Reset a Form.
When you select your radio buttons, you will see a list of radio button properties in the property sheet. Changing these properties will change what your radio buttons look like and what they do at run time.
Many of the styling properties can also be changed using a Cascading Style Sheet. For more information on Cascading Style Sheets, see Using Cascading Style Sheets.
Choose your property based on the task you wish to perform:
If you want to change the contents of the radio buttons, use the ListItems property to open the List Source Dialog Box.
If you want to change the name of the radio button group that identifies it to the procedure, use the (Name) Property. For more information, see the (Name) Property.
If you want to assign the value selected by the end user to a variable, use the SelectedItem property to open the Binding the Selection Result Dialog Box.
If you want to change the size of the location or size of the radio buttons, use a style sheet or resize the radio button group directly in the form. You can also use the Bottom Property, Left Property, Right Property, and Top Property.
If you want to change the font in the radio buttons, use a style sheet or use the Font Property.
If you want to add a border to the radio buttons, use a style sheet, the Border Property to determine whether you have a border, the BorderColor Property to determine the color of the border, and the BorderWidth Property to determine the width of the border.
If you want to change the number of the columns or rows displayed, use the Columns or Rows properties. For more information, see Determining the Layout of Your Radio Buttons.
Note: The size of the radio button group also determines how many rows or columns you see.
If you want to make the radio buttons inactive or make it invisible, use the Enabled Property to determine whether the radio buttons are active or not. If the radio button is inactive, nothing will happen when the end user clicks it. You can also use the Visible Property to determine whether the radio button is visible to the end user or use a style sheet. For more information, see the Enabled Property and the Visible Property.
If you want to change what the cursor looks like when it is on top of the radio buttons, use the CursorPointer Property or use a style sheet.
If you want to display a tooltip when the cursor is on the top of the radio buttons, use the ToolTipText Property.
If you want to assign a Help topic to the radio button, use the Help Property. For more information, see Assigning Help to Your Forms and Controls.
If you want the end user to be able to tab to the radio buttons, use the Tabstop Property.
If you want to move the radio button to another layer, use the Layer Property. For more information, see Layering Controls.
If you want to control the display order of the radio button when more than one control is overlaid, use the ZIndex Property. For more information, see the ZIndex Property.
There are three factors that determine the layout of the radio buttons in your radio button control:
The order in which the buttons are laid out is from top to bottom, and then left to right, as shown in the following image.
For example, for the following radio button control, Columns has been set to 2, Rows has been set to -1, and the size has been adjusted so that the columns are as balanced as possible.
If you are not careful, some of your radio buttons may not be visible, either because your control is not large enough to handle all of the radio buttons or Rows and Columns are set improperly.
For example, if you set Rows to 3 and Columns to 2 for this radio button control, you will only see six radio buttons, and Sunday will disappear.
To solve this problem, we recommend that if you set Rows or Columns to a positive number, you set the other property to -1 so that you won't accidentally lose any radio buttons.
You must also make sure that your control is large enough to display all of the radio buttons. The Form Editor displays the number of radio buttons that will be displayed at run time.
If your radio button control will have a variable number of radio buttons, we recommend that you consider using a list box control or combo box control instead, so that you can better control the layout of controls on your form.