Jump to content

Different enum strings for each row in array


Recommended Posts

Hello everyone,

I was wondering if there is a way of having an emum or ring control in an array which has different strings for each row?

The array element would be a cluster with two enum controls - the selection of the first would determine the strings available in the second.

Unfortunately I do need to use an array. If I figure it out I'll post back.

Thank you,

Martin

Link to comment

I realise what I asked is impossible, Friday afternoon wishful thinking.

The number of rows the user will need is not known at build time hence the array. Perhaps there is another way of getting what I want.

The standard way to fake this is to have a cluster hard-coded to contain a few entries with a custom scrollbar running down the side. The data you store is an array, but the front panel control is a cluster. Depending on the position of the custom scrollbar, you copy in the selected array subset into the cluster.

Link to comment

I've done something like this with a table control and a ring. When the user clicks on a cell in the table (or tabs to it), I populate the ring with the appropriate set of values, then move it on top of that cell. When that cell loses focus, copy the text from the ring into the cell in the table and hide the ring control (or move it to the next cell). It takes a bit of work, and the interface isn't perfect (you have to click twice in the table cell to select a value: once to get the ring there, the second time to pop it down) but it looks pretty good and works well. I like to fill the entire table with something like "Select..." and also have that as the first value in the ring so it's clear that the user can select a value, and when moving back to a cell that has previously been set I make sure to set the ring control to the matching value before moving it into place.

Link to comment

I was wondering if there is a way of having an emum or ring control in an array which has different strings for each row?

The array element would be a cluster with two enum controls - the selection of the first would determine the strings available in the second.

Unfortunately I do need to use an array. If I figure it out I'll post back.

I realise what I asked is impossible, Friday afternoon wishful thinking.

The number of rows the user will need is not known at build time hence the array. Perhaps there is another way of getting what I want.

Hi Martin

You can do this and I have done it before. Here is a screenshot of an example:

post-10325-0-45759000-1305428250_thumb.p

You just have to use Rings (not Enums - FWIW I don't use Enums as display elements anyways, only as application data) and don't use Strict Type Defs for the Rings, Cluster or Array as then you cannot change the Ring's Strings[ ] property (it throws a Run Time error if I remember correctly).

In the example the UI element is an Array of Clusters where one element is a Ring.

I just use VI Server Refnums to populate the Rings at Run Time (e.g. on changes in the Applications etc...) and they can be different even though they are in an Array.

Cheers

-JG

Link to comment
  • 3 weeks later...

Hi Martin

You can do this and I have done it before. Here is a screenshot of an example:

post-10325-0-45759000-1305428250_thumb.p

You just have to use Rings (not Enums - FWIW I don't use Enums as display elements anyways, only as application data) and don't use Strict Type Defs for the Rings, Cluster or Array as then you cannot change the Ring's Strings[ ] property (it throws a Run Time error if I remember correctly).

In the example the UI element is an Array of Clusters where one element is a Ring.

I just use VI Server Refnums to populate the Rings at Run Time (e.g. on changes in the Applications etc...) and they can be different even though they are in an Array.

Cheers

-JG

What properties of the ring are you changing? In my experience, if you change the ring's strings[] property, it changes existing values to the new values or to <#> if there is no longer a match. I've done this with a combobox (and undefined items disabled).

-B

Link to comment
  • 2 weeks later...
  • 9 months later...

...and they can be different even though they are in an Array.

I revisited this post as someone PM'd me for code.

When I looked at the code the UI structure I posted is actually a Cluster of Clusters (not an Array of Clusters as I thought when I just posted a screenshot).

So what I wrote was wrong regarding Arrays, apologies - it looks like you cannot have different Ring Strings[] in an Array.

The Channels did not need to be dynamic so this was fine as a workaround for this use case.

Here is how I updated the ring (there was only one ring, so searching by ClassName was fine in this case, but you could do it another way) in each Cluster to display different Strings[].

Cheers!

-JG

post-10325-0-84948700-1333765344_thumb.p

Link to comment
  • 2 weeks later...

I've done something like this with a table control and a ring. When the user clicks on a cell in the table (or tabs to it), I populate the ring with the appropriate set of values, then move it on top of that cell. When that cell loses focus, copy the text from the ring into the cell in the table and hide the ring control (or move it to the next cell). It takes a bit of work, and the interface isn't perfect (you have to click twice in the table cell to select a value: once to get the ring there, the second time to pop it down) but it looks pretty good and works well. I like to fill the entire table with something like "Select..." and also have that as the first value in the ring so it's clear that the user can select a value, and when moving back to a cell that has previously been set I make sure to set the ring control to the matching value before moving it into place.

You won't need to click twice to change the value if you position the ring on mouse move rather than mouse click. You can track the mouse and re-position the ring only when the cell changes. If the ring appears on a cell on "mouse over", it will give the user a hint that he can click on it to select a value from a list.

Link to comment

You won't need to click twice to change the value if you position the ring on mouse move rather than mouse click. You can track the mouse and re-position the ring only when the cell changes. If the ring appears on a cell on "mouse over", it will give the user a hint that he can click on it to select a value from a list.

Thanks for the idea. I posted my approach to this several months back at http://forums.ni.com/t5/LabVIEW/array-of-cluster/m-p/1822451#M625032. With that code I can simply change the "Mouse Down" event to "Mouse Move" and get the behavior you suggest. I'm not sure I like the visual results of doing that, and I'm no longer working on the project for which I first wrote that code so no need to improve it now, but perhaps I'll take another look at it the next time I need a similar interface.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.