cancel
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 11
(5,366 Views)

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

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 11
(5,356 Views)
Solution
Accepted by topic author Mankyted
08-27-2015 04: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 11
(5,337 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 11
(5,305 Views)

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 11
(5,296 Views)

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 11
(3,112 Views)

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 11
(3,096 Views)

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
0 Kudos
Message 8 of 11
(3,086 Views)

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

This will gives you index number of selected element

Capture.PNG

Capture1.PNG

0 Kudos
Message 9 of 11
(801 Views)

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

Nothing like replying to a 2.5 year old thread with a bad solution.  Exceptable solutions here, in order, would be 1) use a text ring or 2) use Search 1D Array.


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
0 Kudos
Message 10 of 11
(796 Views)