NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
Mankyted
Posts: 6
0 Kudos
Accepted Solution

get the index of an item selected in a combo box

Hi

 

If I have a list of strings in a combo box and the user selects one from the drop-down, how do I get the index?  I could search the array for the string selected but it seems like double work to create a list and then go back and search it.

 

Thanks

Brendon

 

 

Trusted Enthusiast
P@Anand
Posts: 2,324
0 Kudos

Re: get the index of an item selected in a combo box

[ Edited ]

Hi,

 

 What exactly you want to achieve by getting the index of the selected Item?.. If you want only the index means you can go for the Enum controls that will give you the index as output and you can also get the items by using the property node...

 

:smileywink:

-----

The best solution is the one you find it by yourself
Trusted Enthusiast
Yamaeda
Posts: 2,734

Re: get the index of an item selected in a combo box

It's easier to change to Ring control or Enum which gives the index as default, a Combo box gives a string which must be converted. But if you really like the graphic design and want to use the ComboBox you can deselect "use strings as values" and enter the index as numbers, then do a String to Decimal conversion.

 

/Y

LabVIEW 8.2 - 2013
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV
Member
Mankyted
Posts: 6
0 Kudos

Re: get the index of an item selected in a combo box

Thanks for your responses. 

The plan was to be able to remember the last position that an entry was selected from and automatically scroll to that position the next time the drop down was selected.  I have a list of about 200 items but relevent items are usually nearby each other in the list.

 

I just incremented an int, changed it to string and wrote it into 'StringandValues[]' as a value, much as one suggestion... suggested.

 

Thanks again

 

 

Member
Mankyted
Posts: 6
0 Kudos

Re: get the index of an item selected in a combo box

I just read my response - I meant I was dealing with two combo boxes...