11-21-2017 03:36 PM
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.
11-21-2017 04:14 PM
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
11-21-2017 06:14 PM
I have had success using a list box in these situations.
11-22-2017 08:32 AM
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:
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.
11-22-2017 08:45 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
11-22-2017 08:59 AM
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.
11-22-2017 09:13 AM
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).
11-22-2017 10:07 AM
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.
11-22-2017 03:31 PM - edited 11-22-2017 03:33 PM
Oops. nvm