Example Code

Programmatically Edit Items in Combo Box

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

Overview

This demonstrates a combo box editor that can be used in a running program.

 

 

Description

This example VI allows the user to programmatically edit the list of items within a combo box.  We utilize the Strings[] property of the Combo Box to programmatically change the items within the Combo Box.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Steps to Implement or Execute Code

1) Open the project and Run the VI "Menu List - Top Level"

2) Click the drop-down to observe the current list of items in the combo box

3) Click on the Edit List button

4) Observe the current list of items contained within the array of strings

5) Add/remove items at will, then press the OK button
6) In the main VI, notice that the list of items within the combo box has been updated

 

 

Additional Information or References

This VI must run in the LabVIEW Editor to use the Save Instrument method as it is not supported in executables. This could easily, and probably more appropriately, be accomplished by saving these strings to a configuration file instead of persisting them as an actual edit to the source code. 


Block Diagram

BD.PNG

 

Front Panel

FP.PNG

 

 

 

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

Rod T.

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

Comments
markfranklin
Member
Member
on

The invoke node notes say that it is not supported by run-time engine.


So is this a solution for compiled applications that do need to run on a machine with a run-time engine rather than LV software??????

RT4CY
Active Participant
Active Participant
on

Yes, the Save.Instrument method is only supported in the development environment (see this KB).  Thus, this VI cannot simply be built into an EXE and ported to a machine with only the RTE.  There are a couple alternatives.

1.  Use an XControl instead of a combobox (see this community example).

2.  Load the items from a file to populate the combobox at the beginning.  After editing the combobox, dump the items of the combobox to the file.

Rod T.