LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Combo Box strings[] programmatically in an array

Solved!
Go to solution

Hello,

 

I have an application that has several locations on the front panel where the user can select shared variables using a shared variable control. I would like to replace these controls, which are cumbersome for the operator to browse to select from pusblished variables, to combo boxes that list just the variable names from a currently published library. I have no problem doing this by obtaining a shared variable list and updating the strings[] property in a combo box. I can then easily convert the data types to utilize as shared variables elsewhere in my program.

 

However, I have a couple of issues. First, in a couple of cases, the shared variable controls are inside an array, and I don't know how to populate the combo box selections in the array. Perhaps there is an easy way that I am missing...?

 

Second, there are a lot of shared variable controls that I will need to update to combo boxes and in each case, I have to programmatically populate th combo boxes. Is there an easier way to do this with custom controls or type defs or something, so that I can just drop a control on the front panel that will always be populated with the shared variables in my library?

 

Thanks in advance for the help.

 

Michael Hampson

XL Automation, Inc.

Michael Hampson
President
XL Automation, Inc.
0 Kudos
Message 1 of 12
(6,928 Views)

OK, so I partially answered my question. I created a property node for the array that contains the combo box, right clicked on the prperty node and selected "link to", moved through the sub lists till reaching combo box. and selected the Strings[] property. Then I changed it to write and was able to populate it with my shared variable list programmatically.

 

So, the question remains; is this the best way to do this when I have a lot of shared variable combo boxes on my front panel? It would be nice if I could create a custom control combo box that would automatically populate itself programmatically whenever the vi is run.

 

Thanks,

Michael Hampson

XL Automation, Inc.

Michael Hampson
President
XL Automation, Inc.
0 Kudos
Message 2 of 12
(6,925 Views)

Not sure I fully understand your user interface.  Am I correct that you have several comboboxes, and each one contains an identical list of shared variables?  You could look into writing an Xcontrol.  You could build an array containing a reference to each combobox, then use a for loop to populate all of them by looping through the references.  You might be able to let the code build the array of references for you, by obtaining a reference to every control on the front panel (this is a VI property) and then extracting the ones that refer to comboboxes, although you'll need additional code if not all of your comboboxes need to be populated with the shared variable list.

Message 3 of 12
(6,918 Views)

Hi,

I'm not totally sure I understand exactly what you need to accomplish on the user interface.

 

If you have several combo boxes that need to have identical lists of all the shared variables then what you can do is create a type def of the first combo box for which you created the property node and populated with the shared variable list. You will then be able to simply drop this type def combo box anywhere else and it should automatically have the same drop-down list of shared variables.

 

If you need to update the list of shared-variables that appear on one or more combo boxes then you will need to use a property node for each instance of an update that you wish to perform on the combo box. The property nodes should be contained in loops or some programming structure that will allow you to transition between the different sets of shared variables that should appear in the drop-down list of the combo boxes. I have attached a simple VI that shows a simple update of the combo box

 

If you are still having any issues at all with this part of your application, please feel free to respond with more questions and any details that may help us solve the problem.

 

Regards,

James D. 

James D.
Applications Engineer
National Instruments
Message 4 of 12
(6,881 Views)

I have several combo boxes that all need to show the same list of strings. Right now, I am updating the strings[] property of all combo boxes. I'm not sure about the type def solution; I don't think that the values in the strings[] property are saved as part of the type def like they would be in an enum. I'm not positive though.

 

Michael

Michael Hampson
President
XL Automation, Inc.
0 Kudos
Message 5 of 12
(6,875 Views)

Make a sub-vi Action Engine (AE) which stores an array of control references and also accepts a string array.

 

This AE can have a Store-action which'll store an array of control refrences (your combo boxes) and a SetList-action which'll loop though all controls and set the strings[] property.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 12
(6,865 Views)

Ok, that sounds like a neat idea, but perhaps a little above me. I'm not sure if that saves much time programmatically, but I will look into it. I don't really know what an Action Engine is, but I will do a little research. Thanks for the suggestion.

 

Michael

 

Michael Hampson
President
XL Automation, Inc.
0 Kudos
Message 7 of 12
(6,861 Views)
Solution
Accepted by topic author xlAutomation

I rarely disagree with Ben, but an Action Engine seems to me like overkill for a task you want to do once when the application starts.  Just build a reference of all your comboboxes (shouldn't be too much work unless you have a huge number of them), then loop through the array, as shown:

Array of Combobox Refs.png

Message 8 of 12
(6,849 Views)

Awesome, thanks for the help!

Michael Hampson
President
XL Automation, Inc.
0 Kudos
Message 9 of 12
(6,846 Views)

@nathand wrote:

I rarely disagree with Ben, but an Action Engine seems to me like overkill for a task you want to do once when the application starts.  Just build a reference of all your comboboxes (shouldn't be too much work unless you have a huge number of them), then loop through the array, as shown:

 



I got the impression he wanted to do it several times, in which case your loop could simply be put in an AE.

If you're only doing it once there's really no need for a sub-vi, no. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 12
(6,834 Views)