How Do I Implement a Radio Button? (Magic xpa 4.x)
You can implement a radio button in two different ways. You can have the button contained in one control, in which case it will look like the traditional rectangular radio button. Or, you can have it contained in several controls, which gives you more flexibility in screen design. Let’s look at both options.
You can create a radio button that is totally contained in one control. This sort of radio button will be a rectangular box. To create this kind of radio button:
-
Create a virtual that will hold the choice. In this example, it is variable L.
-
Drag the Radio Button from the Toolbox and drop it on your form.
-
Select your virtual for the Data property.
-
Enter your Items list according to what data you want sent back to the virtual.
-
Enter your Display list according to what you want displayed in the Radio Button.
-
You can also set other properties to determine the number of columns, the font, and other display properties.
Now, the user will be able to choose from the valid values in the radio box at runtime.
Alternatively, you can display the radio button using several controls. This gives you the ability to spread the display over several parts of the form. To do this:
-
Create a virtual that will hold the choice. In this example, it is variable L.
-
Drag the Radio Button from the Toolbox, and drop it on your form.
-
Select your virtual for the Data property.
-
Enter only one item for your Items list according to what data you want sent back to the virtual. In this example, the virtual will contain ‘3’ if the color Green is chosen.
-
Enter only one item for your Display list according to what you want displayed in the Radio Button. This part of the radio button will display ‘Green’.
-
You can also set other properties to determine the number of columns, the font, and other display properties.
Choosing the same variable for each of the radio buttons “hooks” them together, so they act as a unit. That is, if you click on one of the buttons at runtime, the previous choice is blanked out. Also, when you are working with the buttons, they move as a unit. However, they are still separate controls and you can edit and move them separately.
The Online and Rich Client Samples projects (program HG18 and RHG18)