LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create checkboxes programmatically

Solved!
Go to solution

Hello,

I have an array of "n" waveforms I got from a cDAQ device, each with their own channel names.

I am trying to create multiple checkboxes with n elements with each bolean text containing each channel names. The "n" elements of the checkbox should resize when sometimes there are 3, 4 or 5 waveforms.

Should I use a cluster? How do I change the bolean text and checkboxes elements programmatically?

0 Kudos
Message 1 of 7
(4,412 Views)

Use an array of clusters, each cluster containing a checkbox and a string indicator for the name, then resize the array and array container programmatically as needed.

 

Message 2 of 7
(4,407 Views)
Solution
Accepted by Navalandrevs

Here is a very simple example

 

Channels.png

Message 3 of 7
(4,354 Views)

If you are working with a chart, you can use a Waveform Data type and show the selection check marks in the plot legend. NI DAQmx will automatically set the "NI_ChannelName" attribute of the waveform and as long as the "ignore attributes: is NOT checked, what you asked for will be automatic, no code required.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 7
(4,318 Views)
altenbach escribió:

Here is a very simple example

 

Channels.png


Thank you so much, It is just what I needed.

0 Kudos
Message 5 of 7
(4,309 Views)

OF course you should "disable, not greyed"  the string so it acts more like an indicator and cannot be modified by the operator at run time. Only the checkbox should be enabled. Modify as needed.

 

If the array size can get big, it might be better to enable the scrollbar and keep the number of visible elements constant. A control that changes it's size significantly at runtime is often not compatible with a nice UI. (e.g. You suddenly might get overlap or it might extend outside the visible front panel area.)

0 Kudos
Message 6 of 7
(4,301 Views)

You may also be interested in doing this with a single column listbox, showing a checkbox as a selection item in the form of a glyph.  Here is a demo showing how this can be done.

 

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

 

Of course a normal listbox can be used for multiple item selection too but I prefer the checkbox for the UI rather than using CTRL for multiple item selection.

Message 7 of 7
(4,288 Views)