No-Select Radio Buttons
By Mark Derwin
Most of us remember the old-style radio buttons from our old cars. You pushed them in to make a station selection and pulled them out to set them. One station was always selected. Of course, there were ways around that. There were ways to make it seem as if none of the buttons were pushed. That’s the
theme of this article.
A number of users have asked me how to display a radio button without having anything selected (See Screen 1).

Screen 1
There are two types of radio buttons that require separate techniques. The first is a Radio Button with a hard-coded list of values. In this case, you just need to write code as follows:
Compute
Form.Radiobutton.Listitems.focindex=0;
Form is the name of the form. Radiobutton is the name of the object.
You must also make sure to set the form as show_inactive before issuing this command.
If you are populating the radio button from a stack, it’s a little trickier. What I do is create an extra entry at the end of the stack. When I place the radio button on the form, I make it long enough to only display the number of items that I want. The selected item, in this case on row 6, cannot
be seen. You cannot scroll a radio button.
When you check to see which row the user selected, if it is higher than the number of items on the screen, you know the user has not made a selection. You can prompt them to do so.
The code for this application is as follows:
MAINTAIN FILE car
Case Top
For all next Country into stk1 -* Loads
-*Radio Button1
Compute
stk1(stk1.foccount+1).country = 'test';
Winform Show_Inactive Form1
Perform Set_to_none;
Winform Show Form1;
EndCase
Case Set_to_none
Compute stk1.focindex = stk1.foccount;
Compute
Form1.Radiobutton2.Listitems.focindex=0;
Endcase
END
During the application, issuing PERFORM Set_to_none unsets the selections of the radio buttons.
|