ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Enum Selection

Hello,

 

I have a .NET class that defines an enum, e.g.:

 

public enum Devices
{
  FOO = 1,
  BAR = 2,
  BAZ = 3
}

How can I provide a way for the user to select an item from the enum? Ideally using a Ring, but a text box with the name would work OK.

 

Currently the only way I can think of is to add a new function to the .NET assembly that uses reflection to accept a name and give a value, then attach the function call to a text input, but ideally I would prefer to solve this in LabVIEW and not change the assembly.

 

Note: the real enum has 200 entries, and is frequently updated. I don't want to hard-code it into LabVIEW.

 

Thanks!

 

 

0 Kudos
Message 1 of 5
(4,290 Views)

You can use the BCL static method Enum.GetNames() to get a list of strings for each enum that you could use to auto-populate the ring at run-time.

 

https://msdn.microsoft.com/en-us/library/system.enum.getnames(v=vs.110).aspx

 

To make things easier you could add this as a public method to your .NET assembly so that your LabVIEW code can retrieve the list and update the ring.

0 Kudos
Message 2 of 5
(4,261 Views)

Thanks for replying. How do I bind the ring to the list?

0 Kudos
Message 3 of 5
(4,241 Views)
0 Kudos
Message 4 of 5
(4,229 Views)

Great, thanks!

0 Kudos
Message 5 of 5
(4,216 Views)