LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Select combo box from string/array

Solved!
Go to solution

Dear all,

 

I want to select combo box based on string input, I don't know how to do that. I have a combo box and the value is taken from a database, what i want to do is i want to edit the combo box selected value based on existing value in the database. e.g i have  A, B, C D strings in my combo box, then in my database i have a field with C string, i want to change the C to A. I can get the C value into a string format, but i don't know how to make the C value to be in the first position of combo box so the combo box strings order will be C, A,B,D.

 

Thank you

0 Kudos
Message 1 of 8
(7,819 Views)

You refer to changing the value of the combobox, but the end of your message indicates you want to change the list of items in the combobox. These are two different things. The value of the comboboxcan be set by simply writing a string to it. The combobox items can be updated programmatically by writing a 1D array of strings to the Strings[] property.

0 Kudos
Message 2 of 8
(7,817 Views)

My apologies if my question is not clear. the point is i want to change the order of a combo box value based on a specific string. if i have combo box with A,B,C,D strings, then how can i change the order to C,A,B,D where C is a string from a database.

0 Kudos
Message 3 of 8
(7,812 Views)

I told you. Use the Strings[ ] property. Right-click on the combobox and select Create -> Property -> Strings[ ]. Place it on the block diagram, change it to "write" and then wire a 1D array of strings. Property nodes are discussed in the LabVIEW Help.

0 Kudos
Message 4 of 8
(7,810 Views)

i know how to do that, i did it to populates data from my database to combo box. but what i want is change the order of existing combo box value. thank you for your help.

0 Kudos
Message 5 of 8
(7,799 Views)
Solution
Accepted by topic author ijan

Then just write a new array of strings, with the elements in the new order, to the "Strings[]"-property.

 

I.e. You need to code something that lets you build an array of strings with elements in the order you want them to be. If this is a reordering only you could do something like:

 

-Retrieve the Strings[] array from the combo box using a property node.

-Find position of the element you want to place first and use "delete from array", which returns the new array and the deleted element.

-Build a new 1D array from the deleted element and the remaining array. Feed it to a second combobox property node's Strings[] property.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 6 of 8
(7,793 Views)

Rearrange the array however you want it and write to the Strings[] property.  You may also have to edit the value in order to keep the right string visible.



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 7 of 8
(7,791 Views)

 

Thank you JarleEkanger, your solution work perfectly.

 

array

 

0 Kudos
Message 8 of 8
(7,781 Views)