03-14-2016 11:54 AM - edited 03-14-2016 11:55 AM
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!
03-14-2016 01:59 PM
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.
03-14-2016 03:13 PM
Thanks for replying. How do I bind the ring to the list?
03-14-2016 03:19 PM
03-14-2016 03:23 PM
Great, thanks!