07-07-2020 05:48 PM
I have an array of clusters where each cluster contains two combo boxes. When one string is selected in the first combo box, I want to update the available option strings in the second. For example, if you selected "Apple" in the first combo box, your possible choices for the second combo box would be: Gala, Fuji, Red, etc.
My problem is that I cannot seem to update the "Strings[]" property of the ComboBox inside an array element. I have figured out how to successfully write a value, but the Strings[] property does not seem to get changed correctly. I can write both value and Strings[] for a SINGLE cluster, but when I put them into an array it does not work. I tried putting the code into a flat sequence to make sure that the value and Strings[] on the new cluster are written first before replacing the cluster into the array.
My strategy thus far is to build up a new cluster and set the Value and Strings[] properties using the Controls[] array and then indexing each ComboBox to write a new value and list of string choices. Next, I replace the cluster (array element) that changed using the "In-Place Element Structure" and then finally write that result into a local variable for my array.
It is important that my original array of controls on the front panel be updated, not a "new" array or copy, thus I am unable to figure out a simpler way to do this using Dataflow programming. I had previously experimented with using the Replace Array Element block, but since the output of that is a new array, that will not work for me (unless I write it into a local variable as I have done with the in-place element structure).
I have shown an image below where my "New Element" is the cluster that will replace one of the clusters in the array. It shows that the "Hello" and "Goodbye" string values were transferred successfully to the new array. However, the option strings for the New Element are A,B,C and this is not being transferred to the new cluster element inside the array, as shown in the second picture where the option strings are seen to be x,y,z. I have attached a simple example VI as well.
Thanks for any help or suggestions.
Solved! Go to Solution.
07-07-2020 08:06 PM
The current Value isn't part of the datatype for the Array Element (i.e. the cluster), so you can change it however you like (e.g. with In-Place Element Structure, or Replace Array Subset), but the Strings[] property is I believe part of the type of a Combo Box.
Since all elements of an array must be of the same type, you can't have an array of clusters in which the elements have 'different types'.
Some possible workarounds might include:
In the latter case, the Filter Event (with question mark in the event name) is used to trigger an Event on the Mouse Down over the array.
Then, the Strings[] property is rewritten.
This actually updates the Strings[] property for all of your elements in the array (not just the one you clicked) but since you only see the dropdown for the one you clicked, and the values don't change, it doesn't matter (at least in general, perhaps you care).
07-08-2020 12:44 AM
Thanks for the tip and links.
The fact you were able to produce so many links is evidence of poor research or improper search terms on my part. I read some other threads not specific to combo boxes that said the same about all elements of the array having the same properties. I guess my trouble was not identifying that Strings[] is a property as opposed to a value of sorts.
I understand the nuances of the clever solution provided. You are only viewing one combo box, but all of the Strings[] properties have changed for all elements. However, you wouldn't know until you clicked on one, which would change the properties for all again. Yes, in my application I'm really only concerned about storing the value, the Strings[] property is just for convenience to the user. So, that would work nicely.
Thanks again.