wallage Posted October 21, 2010 Report Share Posted October 21, 2010 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 Quote Link to comment
Francois Normandin Posted October 21, 2010 Report Share Posted October 21, 2010 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.) Quote Link to comment
crelf Posted October 21, 2010 Report Share Posted October 21, 2010 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. Quote Link to comment
hooovahh Posted October 21, 2010 Report Share Posted October 21, 2010 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. Quote Link to comment
asbo Posted October 21, 2010 Report Share Posted October 21, 2010 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'. Quote Link to comment
ShaunR Posted October 21, 2010 Report Share Posted October 21, 2010 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. 1 Quote Link to comment
wallage Posted October 22, 2010 Author Report Share Posted October 22, 2010 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. Quote Link to comment
asbo Posted October 22, 2010 Report Share Posted October 22, 2010 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. Quote Link to comment
Minh Pham Posted March 8, 2011 Report Share Posted March 8, 2011 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: Quote Link to comment
viSci Posted September 19, 2011 Report Share Posted September 19, 2011 (edited) You can also use the attached vi to determine the array element click on and then use the array selection properties to produce a highlighted effect on the selected element.Find Arrary Element Clicked On.vi Edited September 19, 2011 by sachsm Quote Link to comment
Ravi Beniwal Posted September 19, 2011 Report Share Posted September 19, 2011 I have also used ARRAY of CLUSTERS, where the cluster contains Numeric and Boolean indicators, or in one case even a 2D Picture and a Boolean, to show the selected item. Works pretty well! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.