LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Edit enum items at runtime

Is it possible to edit which enum items display at runtime, on the front panel?

I.E. suppose you have an enum of values

One
Two
Three
Four
Five
Six

And suppose you read from an ini file that tells you what options this user has, and they only use

One
Three
Five

Is it possible to make only those three show up on the front panel when the enum is clicked? (Not greyed out, but a shorter list, supposing the user is easily confused by extra options...)
0 Kudos
Message 1 of 6
(6,309 Views)
Enums have a property node where you can assign an array of disabled items.  It won't make them disappear, but it will grey them out and keep them from being selected.
 
See the attached VI.
0 Kudos
Message 2 of 6
(6,295 Views)

NO, you cannot show different items in an Enumerator at run-time.

There is a property called Strings[] for the Enum, but it is writable only at edit-time, not at run-time. Smiley Sad

So, you dont have any way of altering the list displayed in an Enum for different levels of users, for example, Operator & Engineer.

But if you use Menu Ring, you can do so, because there exists a property called Strings[] & Strings And Values[]. You can write to these at run-time. If you use the 2nd property I ve mentioned, you can even alter the ring values for the corresponding items at run-time.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 3 of 6
(6,291 Views)


@wpolk wrote:

Is it possible to make only those three show up on the front panel when the enum is clicked? (Not greyed out, but a shorter list, supposing the user is easily confused by extra options...)


I missed this part of the post when I wrote my original reply.  Parthabe is correct in that you cannot shorten the list and that you would need a text ring or menu ring in those cases.

But if it must be an enum, I think my solution would work for you.  A greyed out list item really shouldn't confuse anyone.  People should be used to seeing greyed out, unselectable items.  You see such a thing all the time in any windows application.

Message 4 of 6
(6,274 Views)

Yes the two things that cant be done with enums are runtime changes and sparse numbers.  The purpuse of an enum is for the developer not necessarly the user of the application.  Enums are ways to create known sets to simplify programming.  Being able to change this at runtime would cause program problems such as enums wired to a case structure,  if you add a value your code would have unhandled cases.  Unfortunatly you will have to use rings for the GUI.

Paul

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 5 of 6
(6,270 Views)

... or have multiple enums controls and just show the one that applies at the moment.

Michael A from LAVA once wrote something to effect that the GUI should not dicate your data structures. So using a ring on the GUI and an enum behind the scenes may be the way to go.

Trying to help,

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 6
(6,266 Views)