NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
wpolk
Posts: 25
0 Kudos

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...)
Knight of NI
RavensFan
Posts: 15,969
0 Kudos

Re: Edit enum items at runtime

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.
Trusted Enthusiast
parthabe
Posts: 2,506
0 Kudos

Re: Edit enum items at runtime

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. :smileysad:

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.


LabVIEW - Wires that catch bugs!
Knight of NI
RavensFan
Posts: 15,969

Re: Edit enum items at runtime



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.

Trusted Enthusiast
falkpl
Posts: 2,346

Re: Edit enum items at runtime

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
Knight of NI
Knight of NI
Ben
Posts: 16,150

Re: Edit enum items at runtime

... 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

Ben Rayner
Who is now transitioning to John Galt.. just building Rayner's Ridge
Rayner's Ridge is under construction