The intended purpose of a radio button group is to select one (and only one) option from a set of choices. Microsoft has a detailed article on radio button usage guidelines on MSDN. (Although I should note that I don’t agree with all their guidelines).
LabVIEW introduced the radio buttons control in version 7.1. [Before then you had to write diagram code to ensure that only one radio button in a group was TRUE at a time, which was very annoying. Individual radio buttons are still in the palettes and I sometimes see them being used inappropriately, e.g. in place of a checkbox].
Unfortunately, the radio buttons control is somewhat confusing to new users. Here are the basics:
- The group of radio buttons is a single control, with a single terminal on the diagram. Like a cluster, you don’t get terminals for the controls inside the group.
- The radio buttons value is an enumeration of the contained button labels.
- Similar to a cluster, you add radio buttons by placing them inside the bounds of the group. (You can also right-click on the group border and select Add Radio Button).
Radio buttons placed from palette
You usually have to perform the following steps for every radio button group:
- Add more radio buttons, if necessary.
- Set the label of each radio button, as you want it to appear in your value enumeration.
- Hide the label of each radio button.
- Set the boolean text for each radio button.
- Adjust or hide the frame.
- Set a group label.
- If the group label is on top of a frame, adjust its colors. [See previous blog entry for details of coloring labels on frames].
You may notice in the Microsoft guidelines, that it’s usually preferable not to have a frame around a radio button group. In many cases, frames add unneeded visual clutter. So, for your convenience, here is a sample (saved in LabVIEW 2009) of a radio button group with no frame: Frameless Radio Buttons.vi
There are some things to be aware of when using this control:
- The background of the group is opaque so that you can see where the edge is in case you want to use right-click menu items.
- For radio button groups in System tab controls (or on other backgrounds that are not “System Panel & Object” color), you should use this version with a transparent background instead: Frameless Radio Buttons Transparent Background.vi
- The radio buttons group is set to automatically “Arrange Vertically.”
- The auto-arranging makes it easy to add new radio buttons and have them placed properly.
- The auto-arranging avoids the problem of the invisible frame clipping the radio button boolean text.
- Unfortunately, however, the frame does not resize while you are editing the radio button boolean text. If you type longer text into it, it will be cut off until you finish the text edit.
- Each radio button in this group has a small, extra decoration so that they meet the Microsoft spacing guideline when auto-arranged vertically.
- To add more radio buttons and maintain the spacing, use the right-click menu item Add Radio Button or duplicate one of the radio buttons in the group.
- To customize the item names of the group’s enumeration, you have to show the label of each radio button, edit it, and hide it again. You may prefer to make your own starting version with all the labels visible.
View the full article