Jump to content

highlight array elements


wallage

Recommended Posts

I have made a frontpanel with 2 numeric arrays.

I want to loop through these arrays and have two indicators to show the current element values but also use the loop counter to highlight the current element being processed.

I can't figure out how to highlight (use different background color) an individual array element.

NI says it is not possible but there must be a way to do this right?

Ooh sorry forgot to mention that I'm using LV8.6.1

Link to comment

If NI says it's impossible, then I guess you should believe them. There might be a workaround for you to achieve the same result but at the expense of more complex code.

You cannot get a reference to a single array element, just a reference to the type of element. Hence, modifying its background color will change it for all elements at once.

If you absolutely need to change the background color of individual cells, then you should take a look at Multi-Column Listboxes (MCL). The Item Names property lets you set the values from an array of strings and the MCL allows for single cell differentiation (color, font, background, etc.)

post-10515-075512200 1287665982_thumb.pn

Link to comment

Arrays are collections of elements that all shal exactly the same properties (the data can be different, but nothing else) - that's why you can't change the background color of individual cells without changing the background color of all the cells. François' right - try a multicolumn listbox.

Link to comment

I've posted a workaround for this kind of problem before but it seems very hokey. You can make a series of single elements, and control them as if they were an array, but this would allow you to get the reference to each element individually.

So for an array of string, just make 5 strings, and control each individually, and control their contents with a vertical scroll bar so they appear to be an array who shows 5 elements at a time.

Here's my example that gets the references to each element for key focus, you could use this same technique for controlling background color. There would obviously be some more work needed to keep track of the background color of each element.

http://lavag.org/top...dpost__p__74535

But as Crelf said a true array has the same properties for each element of the array because each element in the array must be the exact same other than the data in the element.

Link to comment

Another method is you can overlay a boolean array (flat square classic buttons work best) where the booleans are transparent except for the true state border colour. Then you just use the number to boolean array primitive to set one or more booleans "True" for the value or values you want to highlight in the main array. This will create a border around the value. But if you move it behind your array and make your array transparent, you can also make the boolean array "True" state bg coloured and it will look like you changed the background.

  • Like 1
Link to comment

One step further would be to take a approanch like hooovahh's and wrap it into an XControl implementation - this is what I thought of when François hinted at 'more complex code'.

Thanks for all you replies.

I have not experience with XControl implementations what does it mean?

Another method is you can overlay a boolean array (flat square classic buttons work best) where the booleans are transparent except for the true state border colour. Then you just use the number to boolean array primitive to set one or more booleans "True" for the value or values you want to highlight in the main array. This will create a border around the value. But if you move it behind your array and make your array transparent, you can also make the boolean array "True" state bg coloured and it will look like you changed the background.

Thank you very much. I think I'll go for this approach.

I tried this with a color box array but with the classic boolean control it looks much nicer.

Link to comment

Thanks for all you replies.

I have not experience with XControl implementations what does it mean?

Here's a good starter from NI: http://zone.ni.com/devzone/cda/tut/p/id/3198

It would be a way, for example, that you could take ShaunR's implementation and have it appear as a single control/indicator on the block diagram and have the code that manages the boolean's state to be hidden from the user.

Link to comment
  • 4 months later...

Another method is you can overlay a boolean array (flat square classic buttons work best) where the booleans are transparent except for the true state border colour. Then you just use the number to boolean array primitive to set one or more booleans "True" for the value or values you want to highlight in the main array. This will create a border around the value. But if you move it behind your array and make your array transparent, you can also make the boolean array "True" state bg coloured and it will look like you changed the background.

Nice workaround mate.

I normally use ARRAY of CLUSTERs to do this purpose as you can access each cluster element (contains 2 controls/indicators that you can change the

colour property). here is the result:

post-11757-0-03117000-1299553925_thumb.j

Link to comment
  • 6 months later...

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.