LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combo box selection update

Solved!
Go to solution

I have the following combo box:

 

Item  value

A      aaaa1

B      bbbb2

C      cccc3

 

Suppose the second Item is selected.

How can I programatically select the next item?

 

OBS: I don't want change an item name (String) or Value.

 

0 Kudos
Message 1 of 10
(3,951 Views)
Solution
Accepted by topic author MarcioCardoso

If I'm understanding you correctly, you just want to programmatically select the next item in the combo box, correct? If so, the following code would do it, it just finds the index of the current item and increments it then rolls back to 0 if you're at the end of the combo box.

 

combo box snippet.png

 

--Ryan S.

0 Kudos
Message 2 of 10
(3,931 Views)

Yes, thanks.

 

And now, there is an easier way to implement the following code?

Type Cast function (converting to a Combo Box's constant) does not work. One case for each item is boring to code...

Regards

 

 

combobox.png

 

0 Kudos
Message 3 of 10
(3,923 Views)

I can understand how coding a case for each item would be boring and I wouldn't recommend it...as for an easier way, what's wrong with the above code? It's not all that complicated, and if you want it to take up less room on the block then turn it into a subVI. As long as you use a reference and not explicitely defined property nodes, then you can just use the above as a subVI to get you the next value.

 

--Ryan S.

0 Kudos
Message 4 of 10
(3,921 Views)

Thank you.

I will use the "case" to select a default value from a .txt file, and then use your code to go to the next items.

 

 

0 Kudos
Message 5 of 10
(3,912 Views)

Oh, ok, I misunderstood your previous post. For initializing, you could use a similar approach with a For loop to find and set the value of the combo box based on a configuration value. The code would look like:

 

combo box2.png

 

--Ryan S.

0 Kudos
Message 6 of 10
(3,905 Views)

Great! Thanks

0 Kudos
Message 7 of 10
(3,891 Views)

Hi.....am a beginer in LabVIEW. Can u plz share this vi ?

0 Kudos
Message 8 of 10
(2,502 Views)

Hi Parvathi^4,

 


@Parvathiiii wrote:

Hi.....am a beginer in LabVIEW. Can u plz share this vi ?


As a beginner you should go through all those Training resources offered at the top of the LabVIEW board.

There you will learn about "code snippets" and how to use them.

 

(The code posted 8 years ago is presented in such snippets!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(2,498 Views)

how to get the block value string?

0 Kudos
Message 10 of 10
(2,496 Views)