Showing results for 
Search instead for 
Did you mean: 

Changing number of items in combo box at runtime

Go to solution

I'm trying to change the number of items shown in one of my comobo boxes.


I have been through the help and this forum and have the values within the combo box changing just fine, but in one scenario I want to go from three options to 2. Then depending upon other choices back to 3.


I'm assuming that I need to use a property node but I can't figure out which one.

0 Kudos
Message 1 of 11

You can use the Strings and Values [] property if you need to change the options and their custom values or just the Strings [] property if you don't need custom values.


The input for Strings [] is just an array of options you want the user to have.

Matt J | National Instruments | CLA
0 Kudos
Message 2 of 11

Thanks Jacobson, but that only shows me how to change the content of each string.


I have a combo box with 3 values that I am settinging using the Strings[] property, however I want to limit this to two values depending on other variables.


Currently it is populated with

EN960:2006 525

EN960:2006 555

EN960:2006 585


I want to change this to





using the Strings[] property yields the result




EN960:2006 585


i.e. the thrid value is left untouched so I need to change the number of options.

0 Kudos
Message 3 of 11

Can you attach a simple VI that you are using that demonstrates this behavior?  


I was able to use a control to write an array of two elements to a combo box with three options and it removed the third.

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 11

Thanks, the .vi is attached.


There are three combo boxes


The content of the 'headform' box depends upon the selection in the 'Standard' and 'Type of test' boxes.



0 Kudos
Message 5 of 11

1.  That height property does not do what I think you are hoping it does.  Might as well just get rid of it.

2. You really should be using an Event Structure here.

3. I'm not seeing the behavior you are describing.  When writing to the Strings[] property, it is replacing the entire array for me.  Or the problem could be coming from if the current value was the third option.  You might want to just set the value to the first option when writing new options to the combo box.

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
Message 6 of 11

Your string arrays have more elements than you think.  You have hidden some of the elements by shrinking the size of the array display on the block diagram, but this does not make the extra elements go away.  You have to delete the unwanted elements by right clicking on each one, then pointing to "Data Operations", then choosing "Delete Element". 

Message 7 of 11
Accepted by topic author CHRISINSPEC

You can use the Reinitialize To Zero method (using an invoke node) before setting the Strings[] property (after defining the default value as an empty array) or create a Xcontrol (you can look at the LabVIEW exemples for xcontrol).



0 Kudos
Message 8 of 11

Thanks for the pointers guys, I'll have a play and let you know.

0 Kudos
Message 9 of 11

Thanks Crossrulz.


You are right that I'm probably not using the most effiecient structures, however at the moment I am just trying to get something that works.  Over the coming months I will be scaling this up to deal with dozens of standards, test types and dozens of headform combinations, I'll look at making it more elegant once I have better understanding of how LabView actually works.







0 Kudos
Message 10 of 11