.netcomboboxlabview

LabVIEW: create a named cluster as source for a ComboBox, containing a .NET object in 'Value'


I come from .NET and am trying to get into LabVIEW ...

The thing I fail is to build a named cluster in LabVIEW. The first element should be called 'String' and contain a id string identifying a .NET object. The second element should be called 'Value' and contain the .NET object. The goal is to fill the property 'StringsAndValues' of a ComboBox with this named cluster for to be able to access the .net object after having clicked its corresponding string in the ComboBox.

Its possible to build a cluster of a string and a .NET object by using the function 'Bundle'. But is there a way to change the automatically created names?

I could not create a empty cluster on the front panel with named elements one of the having my specific .NET object type.

Any help appreciated.

Update, this is actually my best approach: enter image description here


Solution

  • In LabVIEW world it is a bit different than in .NET. Combobox contains strings only. It can not contain other objects.

    Also, named clusters are useless in LabVIEW. Instead, you need to create cluster which will have fields: Name, and Object. Then you create array of such clusters - each element has name, and object which you store there (in your case some .NET object).

    And then, using Combobox string value, you need to iterate through array of those above mentioned clusters, compare Combobox value with Name field, and when it is equal - get your object.

    But there is also another way. You could use Variant Attribute, and build so-called lookup-table (which is hash table, actually). In newer LabVIEW versions (I guess starting from LabVIEW 2019) you could also use Maps or Sets for this.

    I showed two approaches on the screenshot, hope they are clear.

    enter image description here