LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Button Control that allows multiple selection?

I'm sure many have come across this issue. When you create an array of buttons on the front panel, all the button properties change when you change any one button's property.  This is not the case with Radio Buttons. However, the radio buttons by default allow only one selection with a property to allow No Selection.  My question: is there a way to make the radio button control allow multiple or all selected?   I know I can achieve this 1) With a cluster of buttons, but using the value programmatically for a radio button is much "cleaner". 2) Create and array of buttons and separate "floating" labels beside them.

0 Kudos
Message 1 of 9
(7,263 Views)

Suppose I had a "control" with 5 "Radio Buttons" and wanted to know which one was pressed.  I could have it output an Integer from 0..4 (or 1..5) to tell me.  If I wanted to allow no buttons to be pressed, I could add -1 (or 0) to the allowable numeric value.

 

Now do the same thing, but allow more-than-one button to be pressed.  Now you have not 5 (or 6) possibilities, but 2^5 = 32 values that these 5 buttons can represent.  That's the problem with designing a multi-on Radio Button Control -- you end up having to deal with binary numbers, so asking the simple question "Is Button 2 On" gets complicated, as you need to "mask out" the other buttons.

 

When I've had to do this, I either used an Array of Buttons or (in one project) 24 individual Buttons arranged (using the Alignment Tools) into a nice 3 <space> 3 x 4 rows arrangement (that is, three LEDs, a space, and three more LEDs, then three more rows with the same pattern).  [Hmm -- it might have been 4 - 4 x 3, who remembers?].  Trust me, there was a good GUI reason for this (it was acting as a large 2D Radio Button with No Selection possible -- code I wrote ensured pushing one Button On would turn off all others).

 

So to answer, You Can't Do That With Radio Buttons, you need to Roll Your Own.

 

Bob Schor

Message 2 of 9
(7,250 Views)

I have had success using a list box in these situations.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 9
(7,224 Views)

A list box doesn't really work in this case - I would like to be able to show the states of each of the selections such as:

2017-11-22  LabVIEW array of buttons.png

I also realized I need to be able to disable/grey individual buttons so that's another reason an array of buttons won't work. So it seems I am left with implementing using a cluster. 

0 Kudos
Message 4 of 9
(7,196 Views)

Radio buttons are really designed to be a single item selection.  If you want multiple selection then you might want checkboxes, or some kind of listbox.  Here is a demo where I add checkboxes to listboxes.

 

https://forums.ni.com/t5/Community-Documents/Listbox-Multicolumn-Listbox-and-Tree-Item-Selection/ta-...

0 Kudos
Message 5 of 9
(7,192 Views)

If yo want the appearance to be that of a radio control, custom control is the way to go.  A cluster of custom checkboxes can do the trick.

 

1) Create an image file for the True/False cases of a radio control  (or any picture really....)  Make sure the background color of the image matches the background of your target application and ensure they are the same size (in pixels) and overlap well for the best appearance.

2) place a Checkbox on the front panel.  Right-click> Advanced > Customize...   (not sure if making a typdef first would be helpful).

3) Copy your TRUE image to clipboard.  Right-click the checkbox and "Import Image from Clipboard" > "TRUE"

4) Copy FALSE image to clipboard.  Right-click the checkbox and "Import Image from Clipboard" > "FALSE"

 

Now you have a checkbox which appears similar to a radio control entry.

Create a cluster or Array of these custom check boxes depending on your application.

0 Kudos
Message 6 of 9
(7,186 Views)

Just use a cluster of booleans.

Radio buttons, by definition, allow only one selected item at a time (who ever heard of a radio that let's you play 2 stations at once).

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 9
(7,180 Views)

I use an array of clusters. One disabled boolean on top of the cluster that is either transparent (F) or background colored (T).  I use a mouse-up event to detect which item was clicked.

Download All
0 Kudos
Message 8 of 9
(7,167 Views)

Oops. nvm

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 9
(7,151 Views)