LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combo Box Question/Bug

Solved!
Go to solution

I never really used Combo Boxes much at all. I am not sure whether this is expected behavior or a bug. (LabVIEW 2025Q3).

 

I have a Combo Box where the values are different than the displayed items and "Allow undefined items" is unchecked. If I change the value of the Combo Box using a string that matches one of the items, it does not correctly select the item. Am I missing something or is this expected behavior? I am guessing the Combo Box is nothing but a string so it's expected behavior.

 

mcduff_0-1790207931269.png

 

Thanks

 

0 Kudos
Message 1 of 4
(157 Views)
Solution
Accepted by mcduff

@mcduff wrote:

 I am guessing the Combo Box is nothing but a string so it's expected behavior.

I see it this way too.

The Combo Box is an UI element (or constant on the block diagram) which combines the visual part (Mode) and value (M), but on the wire it is simply a string.

Message 2 of 4
(118 Views)
Solution
Accepted by mcduff

It's impossible for it to be any different than that.  The relationship between the item names and the string values exists in the ComboBox controls/indicators/constants.  That relationship doesn't exist anywhere else; it is not part of the data type.  When you send a string to the ComboBox indicator, the indicator looks through its values for a match; if it finds one, it displays the item name; if it doesn't find a match, the only thing it can do is display the string.  When you send the string "Mode", that doesn't match any of the values, so it just displays "Mode". 

On your third example (Command 3), you are just sending a string to the 'type' input to the 'Coerce To Type' function; you are feeding it string data ("Mode"), and coercing it to a string (which is a null operation), that of course yields the string "Mode".

On your last example (Command 4), the ComboBox constant is displaying the item "Mode", but the output of that constant is the value "M", the indicator 'Command 4' has "M" as one of its values, and that value associates with item name "Mode", which it displays.

Numeric rings work the same way.

Message 3 of 4
(65 Views)

As a side note: If you have a strict TypeDef for a ComboBox or Ring, then when you make changes to the item list in the TypeDef, all of the dependent controls and indicators will be updated; but none of the constants will be updated.

Unless ...

There is a hidden property for ComboBox and Ring constants called "Act as Strict Typedef Constant".  If that is set to TRUE, then when changes to the TypeDef's item list are applied, the constant will be updated.  But you have to turn this on for each constant; there's no way to globally change that property for all of the constants.

Message 4 of 4
(19 Views)