LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic combo box in cluster array

Solved!
Go to solution

I have an array of cluster that contains two combo boxes. The first combo box controls what items the second combo box displays by writing to the StringsAndValues[] property node for the second box. The problem I'm having is when I create a new index in the cluster array and select different values in the combo boxes, it changes the dynamic combo box on all indexes in the array. Attached is what I've got so far.

 

Thanks,

Chris

0 Kudos
Message 1 of 11
(5,622 Views)
Solution
Accepted by CLH239

Wow, what are the chances of another thread like this so soon.

 

Check out this other thread and look at Hooovahh's link to see a cool way to change the combo box Strings during run-time to give the appearance of different combo boxes. The reality of it is that you can't have different combo-box types/lists within the same array. So what this does, is check which element you are clicked on and change the combobox behavior accordingly.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 11
(5,618 Views)

YOu see this behavior because of a LabVIEW rule of arrays:

An ARRAY is an ordered collection of IDENTICAL elements.

 

The data may be different among elements in the array, but the PROPERTIES must be the same.

 

To prove it, open an array of something on the front panel and show 3 elements.

 

Paint the first element blue.  Notice how they all turn blue?

 

Change the 3rd one to 23 point italic.  Notice how they all change?

 

In reality, there is only one element, and LabVIEW does some trickery to duplicate it so you see multiple data items.  But when you set the PROPERTIES of some element in the array, you are setting the properties of the one and only element, and they all fall in line.

 

And the STRINGS of a combo box is a property.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 11
(5,595 Views)

Thanks for the link James, that looks like it'll work for me. 

 

Thanks,

Chris

0 Kudos
Message 4 of 11
(5,588 Views)

@CoastalMaineBird wrote:

But when you set the PROPERTIES of some element in the array, you are setting the properties of the one and only element, and they all fall in line.

And the STRINGS of a combo box is a property.


Coastal, this isn't true. The Strings[] property applies for all of the elments of the array and I'm pretty sure it's the same for all of the properties.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 5 of 11
(5,539 Views)

Coastal, this isn't true.

 

Sure, it's true - try it yourself:

 

ComboBox.PNG

 

 

 

Run this program and the lists of ALL THREE combo boxes (plus any more you care to reveal in the future) are set to A, B, C.

That's because under the hood there is really only one set of properties.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 11
(5,519 Views)

Oh, miscommunication, we're arguing the same point.

 

I read " you are setting the properties of the one and only element" as that property is only affecting the one element and the other elements have different properties.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 7 of 11
(5,406 Views)

It's my contention that behind the scenes, there IS only one element (with all itts properties).  The array you see on screen is NOT a collection of independent objects, it's one object with multiple DATA values.

 

If you think about it, that's a sensible way for it to work.  Otherwise, if you decided to show another element, LV would have to CREATE another element with umpteen strings for the combobox menu, and so on.

 

 

That's what I meant by "one and only" element.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 11
(5,398 Views)

@CoastalMaineBird wrote:

 

That's what I meant by "one and only" element.


Yup this is true.  You can actually get a reference to the control in the array, but it is just a scalar reference not an array of references.  There are some tricks to it and LabVIEW and I remember at times this reference wouldn't be to the first element

 

Say you wanted to get the value of the second element in the array using the reference to the element.  If you get the element reference and get it's value, which one will you get?  Well it's depends.  There are tricks to know, like I believe interacting with the second element (as the user at run time) will cause the reference to point to that element.  Attached is a VI that shows this.  Other methods like Highlight Object appear to always pick the first element.

0 Kudos
Message 9 of 11
(5,390 Views)

 There are tricks to know, 

 

 

Well, maybe, but that falls into the basket labelled "implementation details" and I wouldn't rely on any of it.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 10 of 11
(5,374 Views)