LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How order a list box ?

Hello,

I'm trying to order a list box at the same time I’m putting items into it. I found some CVI functions but I can’t understand the explanation. Anybody could send me an example please ?

Function that I used (without order) => InsertListItem
Functions that seem to be useful to order a list (ListInsertInOrder, ListInsertionSort,…)

Thanks
0 Kudos
Message 1 of 4
(4,517 Views)
The functions you are referring to are for the list data type, not list boxes. The list data type is a linked list datatype used for creating and storing dynamic lists in memory. List boxes don't have any built in sorting capabilities. Table controls are the only controls I know of with built-in sorting functionality. If you want to stick with a list box and have it sort, you would have to keep the list of values in your program in an array and programmatically determine at what index to insert each value in order to keep them sorted, then use InsertListItem with that index.

Or you could switch to a 1-column table control, which has built-in sorting functionality (SortTableCells) and could be made to look just like a list box.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 4
(4,507 Views)
You can use the tree control introduced in version 7.0. I've attached a sample program that shows how to configure a tree control to look just like a listbox with a lot more functionality....

- horizontal scroll bar
- tooltips
- multiple item selection option
- drag and drop within the list
- sorting
- search
- customizable right click menu
- columns
- edit item labels at run time

Hope this helps
jared
Message 3 of 4
(4,485 Views)
Hi, I had the same problem two years ago and I solved it as I go to explain. I created a list box as you can see in the bitmap attached. I gave the possibility to the user of my application both to check an item already present in the list and to insert a new one (into the control above). When user finish to digit the new item and press ENTER (as you can see in the source file attached) I put all letters in capital mode, check if there is already in the list box and if no I insert it in alfabetical order. Sorry for my bad english! I hope this example can help you (although I leaved comments in my language...).

Bye.

Peo
Message 4 of 4
(4,448 Views)