Jump to content


Photo
- - - - -

[Eyes on VIs] LabVIEW Radio Buttons without Frames


  • Please log in to reply
No replies to this topic

#1 Christina Rogers

Christina Rogers

    Very Active

  • NI
  • 91 posts
  • Location:Austin, TX
  • Version:LabVIEW 2012
  • Since:1997

Posted 26 August 2010 - 10:36 PM

Posted ImageRadio Buttons

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).
One point of frequent confusion is that the radio buttons look very different when initially placed from the palette than you probably want them to look in your UI:

Posted ImageRadio 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’ll notice that I mentioned that you could “hide the frame.” Many people conclude they can’t hide the frame when they can’t delete it or color it transparent. The trick is, although you can’t color the Modern or System style frames, you can color the Classic one.

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

Posted Image

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.
  • 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