Example Code

Change Properties of Multiple Controls Programmatically

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 VI shows one way to organize the block diagram when attempting to set properties for multiple controls. It does so via creating an array of references and then modifying them in an indexed for loop. 


Description: When attempting to access various controls and set their properties programmatically, it is possible to have a large amount of wires running through the block diagram. This example creates a set of references and adds them to an array. By indexing a for loop and passing those references to the input of a property node, the visible property is toggled with the click of the Test1 or Test2 buttons.

 

When the user clicks on the Test1 or Test2 control, the VI creates an array of eight elements of true or false values depending on the current value of the aforementioned control. This array is then completed by adding the current values of the controls that will not be changed. Finally, the last for loop updates all controls with their due value; either leaves them as is or modifies them accordingly.

 

While this VI simply toggles the visible property, within that for loop any other property of the control can be modified. Alternatively, instead of creating an array of references, it is possible to cluster them; it would not allow for an auto-indexing for loop, however.


Requirements: LabVIEW 2012 (or compatible). Hardware: none.


Steps to Execute Code:

  1. Run the VI
  2. Click on the Test1 control;the buttons appear or disappear with each click.
  3. Click on the Test2 control and observe the same behavior

 

Additional Information or References:

 

Change Properties of Multiple Controls Programmatically FP.png

 

Change Properties of Multiple Controls Programmatically BD.png


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

 

 
Scott G.
AE Specialist
National Instruments

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