10-02-2012 07:40 AM
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
Solved! Go to Solution.
10-02-2012 07:47 AM
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.
10-02-2012 07:53 AM
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.
10-02-2012 07:57 AM
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.
10-02-2012 08:11 AM
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.
10-02-2012 08:19 AM
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.
10-02-2012 08:23 AM
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.
10-02-2012 08:54 AM