Identify Selected Items in a Single-Column Labview Listbox Control

Updated Nov 3, 2020

This article explains how to programmatically identify the selected items in a LabVIEW Listbox Control. By following the steps in this article, you will be able to obtain the item name(s) for the selection(s) made in a either a single-column or multi-column LabVIEW Listbox Control.

Single Column Listbox (Single-Selection)

  1. Create a reference to the Listbox Control, and place it on the block diagram.
    • Right-click on the Listbox Control, and selecting Create>>Reference.
    • Move your cursor over to the block diagram to drop the reference.
  2. Create a property node to access the properties of the Listbox Control.
    • Right-click on the block diagram.
    • Select Application Control>>Property Node.
    • Connect the Listbox reference created in Step 1 to the "reference" input on the property node.
  3. Configure the property node to access the "ItemNames" and "Value" properties.
    • Click the bottom edge of the property node and drag down to expose a 2nd property item.
    • Click on the top item labeled "Property" on the property node, and select "Item Names". (This should be in the bottom section of the list.)
    • Click on the bottom item labeled "Property" on the property node, and select "Value". (This should be one section up from the bottom of the list.)
  4. Obtain the name of the selected item by indexing the "ItemNames" array with the value of the "Value" property.
    • Drop an "Index Array Function onto the block diagram. (Right-click on the block diagram>>Array>>Index Array)
    • Connect "ItemNames" from the property node to the "Array" input of the "Index Array" function.
    • Connect "Value" from the property node to the "Index" input of the "Index Array" function.
  5. Note that the "Index Array" function will return the name of the item currently selected in your Listbox as a string.
Please see the VI snippet, included in the "Results" section, for reference.


Single Column Listbox (Multi-Selection)

  1. Follow steps 1-3 from the "Single Column Listbox (Single-Selection)" section.
  2. Note that the "Value" property is an array of integers (rather than a single integer) for a single column Listbox with multiple selections enabled. This "Value" array will contain a single element for every item currently selected in the Listbox.
  3. Create a for loop to index the "Value" array.
    • To create a for loop, right-click on block diagram and select Structures>>For Loop.
  4. Wire both the "ItemNames" and "Value" arrays to the left side of the for loop.
  5. Disable indexing on for the tunnel connected to the "ItemNames" array.
    • To disable indexing, right-click on the tunnel, and select "Disable Indexing".
  6. Place an "Index Array" function inside the for loop to obtain the name(s) of the selected item(s) by indexing the "ItemNames" array with the value(s) from the "Value" array.
    • Drop an "Index Array Function into the for loop. (Right-click on the block diagram>>Array>>Index Array)
    • Connect the "ItemNames" array to the "Array" input of the "Index Array" function.
    • Connect "Value" element indexed by the for loop to the "Index" input of the "Index Array" function.
    • Connect the "Element" output of the "Index Array" function to the right side of the for loop.
  7. Note that the output of the for loop will now be an array containing the name(s) of the selected item(s) from the Listbox.
Please see the VI snippet, included in the "Results" section, for reference.

Your code should look like one of the following VI snippets, below.

Single Column Listbox (Single-Selection)


Single Column Listbox (Multi-Selection)