Accessing Properties and Methods of Array Elements

Updated Jan 9, 2019

Reported In


  • LabVIEW Base
  • LabVIEW Professional
  • LabVIEW Full

Issue Details

  • I have an array of elements and I would like to programmatically change the properties or call methods corresponding to the elements. How do I do this?
  • I am using an array of a named numeric data type (such as an enum or ring), but, when I set the elements of the array to a variable of the same datatype, it appears that nothing changes or the wrong data is passed. How can I edit the Strings[] property of the named numerics directly so that my strings are copied to every element of the array?


Note: When editing the properties of elements in an array, you will be editing the properties of ALL elements in that array. For example, if you have an array of Boolean buttons and you set the color of the Boolean to blue, all of the buttons will be blue. This is because all elements in an array share the same properties. If your data structure needs to store different properties for different elements, you should consider using a cluster.

To programmatically change properties or call methods for elements in an array:
  1. Obtain a reference to the array of interest. To create a reference to an array, right click on the array terminal from the block diagram and select Create»Reference.
  2. Obtain a reference to the array element within the array. Right click on the Array Reference, select Create>>Property for Array (strict) class»Array Element»Reference. Pass the array reference into a property node.
  3. Specify the array element type. At this point, LabVIEW doesn't know what the element type is, only that it is an element of an array. You need to tell LabVIEW the element type and this is done by using the To More Specific Class function located in the Application Control Palette on your Array Element reference. To create a reference for the target class, you can right click the target class terminal on To More Specific Class and select Create>>Constant. This will create a Generic constant. Click on this constant and navigate the drop-down menu to find the class corresponding to the data type in your array. (Most of the common data types can be found under Generic>>GObject>>Control.)
  4. Access or set the properties of your array elements. Place a property or invoke node on the block diagram and wire the output of To More Specific Class to that node. You now have access to the individual properties or methods available for that type.
The following image demonstrates how to use this method to programmatically change the text stored in the elements in a string array:


Not Helpful