LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get the index of an item selected in a combo box

Solved!
Go to solution

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
(17,746 Views)

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
(17,736 Views)
Solution
Accepted by topic author Mankyted

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! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 11
(17,717 Views)

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
(17,685 Views)

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

 

0 Kudos
Message 5 of 11
(17,676 Views)

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
(15,492 Views)

ComboBoxSettings.png

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 11
(15,476 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(15,466 Views)

This will gives you index number of selected element

Capture.PNG

Capture1.PNG

0 Kudos
Message 9 of 11
(13,181 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 11
(13,176 Views)