LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing cell color in a table based on input

Solved!
Go to solution

Hi guys:)

 

Please refer to my example I've attached. I got an 2d array with som information. 1 row = 1 electric component and it's information. This array is put into a table when you press "Update" in the frontpanel. My goal is that based on index 1 of the array (col2 "Bord"), the color of the tablerows should change color. If the content of the row is S20-1, the color should be red and so on. This kinda works, but I'm having some bugs:

 

-You have to press "Reset" two times in order to make the table white again.

-The first colorchange also changes to color of the whole table. I want my table to be white, and only the rows to change color (Header and unused tablerows should be white).

 

You can change the first element in the array constant from S20-1 to S20-3 and you will see that my program makes to whole table blue on the first colorchange.

 

Is this an error from my side? Or is it a bug in LV (which I doubt)?

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
Message 1 of 16
(9,576 Views)
Solution
Accepted by topic author EvenDeejay

Property nodes execute top to bottom and you have the order reversed. You set the color first, then the active cell, meaning the color will lag one execution behind.

 

Your code is also overly complicated. Here's a quick draft how it could be done. Let me know if you have any questions.

 

 

 

Download All
Message 2 of 16
(9,567 Views)

Thank you Altenbach:)

 

I works as a charm. I only have LV2010 BDS so I cannot create and use Events. Which is a bummer.

 

Well I learned something about property nodes today:) Hopefully I'll learn more when I take the Core 2 and 3 courses.

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 3 of 16
(9,560 Views)

Should be easy to adapt with using a case structure. A single loop with a small delay, and a 3 frame case structure is probably all you need. 😉

0 Kudos
Message 4 of 16
(9,555 Views)

 


@altenbach wrote:

Should be easy to adapt with using a case structure. A single loop with a small delay, and a 3 frame case structure is probably all you need. 😉


 

Here's a quick draft... 🙂 Look ma, no events!

 

Modify as needed.

Message 5 of 16
(9,551 Views)

How can I achieve the same when instead in a table I have to display the results in an array (indicator) one value at a time and changing the BG color of each element depending on the value? I do not seem to find the equivalent of ActiveCell in this case. Please advise.

0 Kudos
Message 6 of 16
(8,363 Views)

@Broni wrote:

How can I achieve the same when instead in a table I have to display the results in an array (indicator) one value at a time and changing the BG color of each element depending on the value? I do not seem to find the equivalent of ActiveCell in this case. Please advise.


Can't do this with an array.  Every element in an array must have the exact same properties.  Only the value can be different.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 16
(8,360 Views)

Thank you, Crossrulz.  I really appreciate your fast response.

As the program runs I have to not only change the color of the cells (one at a time rather than at the end of the program), but I have to display its numeric value as well. Can I use a property node to display the cell value? If ‘not’ how can I achieve this one by one changing the cell color AND displaying its numeric value?

I have no experience working with tables before so I really need some advice.  

Thank you in advance.

0 Kudos
Message 8 of 16
(8,349 Views)

When dealing with tables, it is far better to write all of the values in the table using a 2D array of strings going into the table's terminal.

 

Otherwise, I am pretty sure there is an Active Cell's value property that you can read and write.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 16
(8,346 Views)

@Broni wrote:

Thank you, Crossrulz.  I really appreciate your fast response.

As the program runs I have to not only change the color of the cells (one at a time rather than at the end of the program), but I have to display its numeric value as well. Can I use a property node to display the cell value? If ‘not’ how can I achieve this one by one changing the cell color AND displaying its numeric value?


Just keep your numeric data in a matching 2D array (e.g. in a shift register) and use the table purely for a cosmetic display. Once you know the cell, you can then index into the 2D array to get the value.

0 Kudos
Message 10 of 16
(8,344 Views)