Example Code

Populate Combo Box from INI File

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

Description

Overview

This example demonstrates how to use an INI file to fill in values for a Combo Box.

 

Description

The Config File VIs palette offers an encapsulated way to read and write to standard INI files. First we will generate a config file to use with these functions. This VI is an example of how this can be done. First it opens up the config file, converts the string array to a single string, writes the data to a specified key, and closes the file.

 

5.PNG

 

2.png

If you open up the INI file in notepad you see this information.

 

ConfigFile.png

 

Now that we have a config file we will use it to populate the values of a Combo Box programmatically. To do this we open the config file, read the data at the correct location, parse the string into an array, write the array to the Strings[] property of the Combo Box, and set the value of the combo box to the first item in the array.

 3.png  7.png  

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Download the attached ZIP file (or both of the VIs).
  2. Open and run the "Create Config File.vi" (change values if you want)
  3. Observe how the INI file was created in the folder that the VI executed from.
  4. Open and run the "Populate Combo Box.vi"
  5. Observe how the Combo Box is filled with the information from the INI file.

 

 

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

 

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com

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

Comments
Hecuba
Member
Member
on

I believe that a better and more robust approach to work with INI file is with the use of the functions in the "Configuration Files VIs" subpalette

Mfg. Test Engineer
Certified LabVIEW Associate Developer