DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting multiple items in a listbox

Is it possible to select multiple items in a listbox and insert them into an array. Currently, to get around not knowing if this is possible, I have two listboxes. One has items available and the other has items you want to use. I can either double click or press an add/remove button to move items between the two listboxes. The problem there is that when I move an item from one to the other it puts it at the end of the list. I want to keep the lists in order by channel. My items structure is as follows: "'channel number' 'Channel name'" ie "1 Date\Time"
I can sort this list but it sorts by the first character. If I have channels 1-30. It sorts to 1,11,12,13,14,...,3,30. I want 1,2,3,...,30 I would prefer to select multiple items in the listbox but if I can't, how can I do a better sort with my current method of two listboxes.

Thanks,

AJL
0 Kudos
Message 1 of 12
(5,839 Views)
Hi AJL,

I'm not aware of a multi-selection listbox in SUDialogs. What you can use instead is a SUD table control, which can be configured to have only 1 column. The SUD table control is a little hard to get used to using, but I've had a lot of practice with it and have quite a lot of code to draw from. I certainly have applications where you can select multiple items in a single column.

As to the sorting, you just need to apply the sort condition as a numeric comparison. I have some bubble sort functions I can send you if you wish. I'm not proud of that, but the sorting I've used it for with 100 or fewer items still executes instantly, so I've never bothered with faster methods. The point is that it's real simple code, so you can find and edit the comparison line from

IF val1 > val2 THEN....

to

IF CDbl(val1) > CDbl(val2) THEN...

I'm assuming that all the elements are numeric, otherwise you'd need to use the IsNumeric() function or error checking-- CDbl("xyz") = 0.

Ask if you want more specifics,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 2 of 12
(5,813 Views)
The table works but I have a few questions. How do you get all the selected items into an array? Also, can you turn off the scroll bars. I programatically set the table size but when I set the table width the table border is pushed to the right as if the vertical scroll bar is there. I want to have the border tight to the table column without the scroll bars.

Thanks,
AJL
0 Kudos
Message 3 of 12
(5,809 Views)
Hi AJL,

Here's an example of several things to answer your question:

0) How to create a DIAdem variable to communicate with a SUDialog (OdsValalloc)
1) How to display items stored in a DIAdem variable in a SUD table control column
2) How to trap the items (rows and columns) selected in a SUD table control
3) How to dynamically create a DSN for an Access (JET) database
4) How to issue a quick SQL query with DIAdem's ODBC commands
5) How to display the SQL query results in a table control

Let me know if you have questions,
Brad Turpin
DIAdem Product Support Engineer
National Instruments
0 Kudos
Message 4 of 12
(5,794 Views)
AJL,

Just realized the SUDialog in the last ZIP file wasn't the right version. Here's the application that actually works.

Brad Turpin
DIAdem ProductSupport Engineer
National Instruments
Message 5 of 12
(5,789 Views)
Once again you fixed my problem. Thanks Brad.
0 Kudos
Message 6 of 12
(5,789 Views)
Hi together,
 
Since there is no multiple selection in Enumlistbox in SUD dialog, i wanted to use a table.
But i couldnt get the table to show the values from a user variable definition file (dynamic enumeration list). I fail to assign one column of the table to that user variable.
Below i attach the corresponding files:
where could be the problem?
 
And i was looking through DIAdem help file to look for information, how to define different types of user variables (for example vectors) but i couldnt find enough information. Do you have any document or examples where i can see the defining and usage of different type variables in different controls in SUD dialogs ?
 
thanks in advance
 
kaan
 
0 Kudos
Message 7 of 12
(5,119 Views)

Hi kaan,

What version of DIAdem are you using these days?  DIAdem 10.1, which released in January, 2006, DOES now support multi-selection List Boxes.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 8 of 12
(5,093 Views)
hi brad,
 
i am using DIAdem 10.0, I have a dynamic enumeration list ( 3 columns ) in an .ASC file and i want to display them in a dialogbox. ( using a matrix variable ?)
and in each column user should be able to do multiple selections and then this selection should be passed to DIAdem.
 
Ps: it is not neccessary for me to keep 3 columns in the same file, i can have them in 3 different files if needed.
And if it is possible to do it with matrix variable, how do i define a matrix user variable in a .VAS file ?
 
cheers
 
Kaan
0 Kudos
Message 9 of 12
(5,085 Views)
Kaan,

So if you have 3 different variables each pointing to a different column, you should be able to just set each variable to its own column and display correctly. In other words, you'll just have 3 "arrays" of the enumeration with one in each column. Once you do this it should just work, if it does not, go ahead and attach your ASC and VAS files and we can try to check it out.

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 10 of 12
(5,063 Views)