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