Example Code

Dynamically Add Item To Listbox

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This is a simple example to  add items to a listbox dynamically / programmatically.

 

Description

Ever needed to add items to a listbox in LabVIEW dynamically / programmatically? Here's some example code that shows how it could be done!

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI.
  2. Select items in the listbox. The Selected indicator can display the number of item.
  3. Click add a new one in the list box, print its name and click OK button to add a new item.

 

Additional Information or References 

VI Snippet

148.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,


Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
testproggie
Member
Member
on

True, post is old, but it does what I was looking for. My problem is that I cannot create something that works the same. I can copy of course and it works fine, but not from scratch. If somebody stumbles across this can you explain how the "+add a new one..." portion of this works? How can I create it from scratch?

Robert

crossrulz
Knight of NI Knight of NI
Knight of NI
on

That section just makes the string control and ok buttons visible when the "+add a new one..." is selected.  It is just using a property node to get the available strings from the listbox and then array size to get the number of elements in the listbox.  If the final value is selected, the other controls become visible (again, just property nodes to the other controls).  What part of it do you not understand how to create?



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
testproggie
Member
Member
on

Must be the day I am having. I have created 4 versions now and all work as they should. I don't know why it would not work the first few times I tried it. What would happen is when I clicked on the last item the string control and OK boolean would pop up, the immediately go invisible again as if another action had occured. Not sure why that was happening though. Thanks for the quick response though.