Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
9 ratings:
 4.11 out of 5   

Programmatically Populating an Enum Control



Primary Software:
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:

How can I programmatically populate an enum control with an array of strings?

Solution:

You can use the Strings[] property of an enum control to programmatically populate it. It should be noted that since the strings in the Strings[] property are part of the data type of the enum control, they can only be changed during editing time. So, you will need to set the Strings[] property from another VI so that the VI containing the enum is not running.

The steps needed are:
  1. Open a VI Reference to the VI that contains the enum
  2. Get a Panel reference
  3. Read the Panel.Controls[] property
  4. Based on the Label.Text property search for the enum control
  5. Set the enum control's Strings[] property



The attached VIs demonstrate this technique.
Download both attached files.  Open enum_target.vi, and note that the enum shows only a single choice, Before.  Open Change_enum.vi, and point the file control to the enum_target.vi.  Run the Change_enum.vi.  The contents of the enum control in enum_target.vi should have changed to the string array in Change_enum.vi.


Related Links:

KnowledgeBase 20TEBKLJ: How Do I Programmatically Change the Entries of an Enumerated Type?

Attachments:


Change_Enum.viChange_Enum.vi enum_target.vienum_target.vi


Report Date: 09/09/2004
Last Updated: 11/18/2012
Document ID: 3D8AH34P

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit