LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determining selected files in ListBox

I'm able to list the files found in a directory into a ListBox.  The user can select (highlite) multiple files.  What I'd like to do, however, is to pass this sublist (array) to another Vi to perform some other operations.  I'd also like to place a "Check All" option that saves the user from having to select each file (time consuming).  Does the listbox have these properties, or do I have to keep track (events) of all selections on my own?  Any suggestions?
Message 1 of 10
(4,279 Views)
Here's what you were looking for.  This really isn't a difficult task (< 5 min.).  These forums are not supposed to be used as a crutch, meaning that you should try to figure this out on your own, then if you truly are stuck ask for help.
0 Kudos
Message 2 of 10
(4,277 Views)
And yes, the listbox has the ability to select all files without doing any programming. You just highlight the first file you want, and holding the shift key down, click on the last file. You can use the CTRL key to select multiple, nonconsecutive items. This is all explained in the on-line help. You can simply copy the information from the on-line help into the listbox description to provide help to the user at run-time.
0 Kudos
Message 3 of 10
(4,268 Views)
I'm able (as you did in your example) to capture ALLl the files in the listbox.  In fact, whether I select one, two, five, ALL of the items in the listbox get passed to the array (Items Names Out in your VI).  I can't seem to determine (and then extract) just those selected files.
0 Kudos
Message 4 of 10
(4,256 Views)

To get the list of selected items in a listbox, all you have to do is something like the image below.

You might want to look into some of the resources for learning LabVIEW basics at http://zone.ni.com/devzone/cda/tut/p/id/5199 .

Message Edited by Dennis Knutson on 12-29-2006 06:34 AM

0 Kudos
Message 5 of 10
(4,240 Views)
Actually in the "Clear Listbox.vi" given above only the items which are selected are moved to the "Item Names Out" array or if the "Select All" checkbox is checked, then ALL items are moved to the "Item Names Out" array.  This vi is just an example and reinitializes the "Item Names Out" array each time it loops.  Reposting the vi just in case it got messed up somehow in transition.
0 Kudos
Message 6 of 10
(4,220 Views)
I have two questions (1) I know that the extraction of the selected items is accomplished in the for-loop found in the Timeout case.  I'm just not sure exactly how passing the listbox into the IndexArray accomplishes this.  Also, (2) I noticed this behavior - when I run and let a few items build up, then select a few items, those items show up in the Item Names Out (as expected), but if I click Clear, the first new item that appears in Listbox appears selected (although I didn't select it).
0 Kudos
Message 7 of 10
(4,190 Views)
1.) The 'Listbox' control going into the for loop contains an array of numbers (which are the selected rows).  The 'ItemNames' property going into the for loop contains an array of strings (which is the text in each row of the listbox).  So the 'Index Array' function takes in the 'ItemNames' array and the number from the 'Listbox' control and outputs whichever item is in the 'Listbox'(number) element of the 'ItemNames'(string) array. 2.)  I added code in the 'Clear' event case to clear all selections.  Re-initializing the local variable to the 'Listbox' takes care of that behavior.
Message 8 of 10
(4,171 Views)
I'm wondering why Listbox doesn't contain a property (like ItemNames) that serves the same purpose as passing the listbox into the for loop?  Are there any other hidden properties/side effects available in a listbox.  Is any of this documented somewhere?
0 Kudos
Message 9 of 10
(4,137 Views)
The complete list of Listbox properties is here:

http://zone.ni.com/reference/en-XX/help/371361B-01/lvprop/listbox_p/

0 Kudos
Message 10 of 10
(4,128 Views)