cancel
Showing results for 
Search instead for 
Did you mean: 

combo box selection update

SOLVED
MarcioCardoso
Member
Solved!

combo box selection update

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.

 

9 REPLIES 9
Ryan_S
Active Participant
Solution

Re: combo box selection update

Message contains an image

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.

MarcioCardoso
Member

Re: combo box selection update

Message contains an image

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

 

Ryan_S
Active Participant

Re: combo box selection update

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.

MarcioCardoso
Member

Re: combo box selection update

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.

 

 

Highlighted
Ryan_S
Active Participant

Re: combo box selection update

Message contains an image

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.

MarcioCardoso
Member

Re: combo box selection update

Great! Thanks

Parvathiiii
Member

Re: combo box selection update

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

GerdW
Knight of NI

Re: combo box selection update

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
Parvathiiii
Member

Re: combo box selection update

how to get the block value string?