LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Listbox Sorting alphabetically ?

Hi

 

Is there a cvi function to sort a listbox alphabetically ?

 

Help share your knowlegde
0 Kudos
Message 1 of 4
(4,212 Views)

Shako:

 

As far as I know, there's nothing built in to CVI to automatically sort the items in a list box.

 

If you could use a tree control instead of a list box, look at the SortTreeItems() function, and the treesort.cws project that ships with CVI.

 

CVI does have a Sort() function in the Analysis library to sort an array of doubles, and a qsort() function, which handles array manipulation, but you write your own comparison function for it.  See the CVI help for both functions.  To use either function with a list box, you would need to read your label/value pairs into array, sort the arrays, and write them back out to the list box.  The Analysis library Sort function will only work on the list box values, not on the labels.  qsort can work on labels as well as values.

 

0 Kudos
Message 2 of 4
(4,202 Views)
Here's a simple example of sorting the list box labels.  Not very elegant, but it might give you a few ideas.
0 Kudos
Message 3 of 4
(4,182 Views)

Thanks for the info.

I will be creating my own sorting function.

Help share your knowlegde
0 Kudos
Message 4 of 4
(4,173 Views)