Showing results for 
Search instead for 
Did you mean: 
Reply

get the index of an item selected in a combo box

Solved!
Go to 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

 

 

0 Kudos
Message 1 of 8 (4,175 Views)
Reply
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...

 

Smiley Wink

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 8 (4,165 Views)
Reply
0 Kudos
Solution
Accepted by topic author Mankyted
‎08-27-2015 06:09 PM

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

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 3 of 8 (4,146 Views)

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

 

 

0 Kudos
Message 4 of 8 (4,114 Views)
Reply
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...

 

0 Kudos
Message 5 of 8 (4,105 Views)
Reply
0 Kudos

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

Hi

 

May I ask how to deselect "use strings as values" and enter the index numbers for combobox?

 

Thank you

0 Kudos
Message 6 of 8 (1,921 Views)
Reply
0 Kudos

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

ComboBoxSettings.png

 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 8 (1,905 Views)
Reply
0 Kudos

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


tiho wrote:

May I ask how to deselect "use strings as values" and enter the index numbers for combobox?


That sounds like a Ring to me.  A ring shows strings, but its data type is actually a number.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

The discussions from the Advanced User Track is not over. Join in the conversation: 2016 Advanced Users Track
NI-Week attendees, click here to take the survey for the sessions you have attended!
0 Kudos
Message 8 of 8 (1,895 Views)
Reply
0 Kudos