LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change the color in a row of a list box

Hello everyone,

 

I have a question, how can I change the color in a specific row of a list box if I need to make the compare two values ​​within it?

 

It works in the following way: You can add one or more rows, within each row you can place a current value and one that is necessary, if the current value is less than the necessary one, the row must be painted in red, otherwise continue in white color. Is there a way to do this?

Mocte117_1-1686437486123.png

I tried to use a properties node but it didn't work

Mocte117_0-1686436869170.png

 

VI attached

 

0 Kudos
Message 1 of 6
(1,240 Views)

Just iterate over the active cell for column 3 and color based on the numeric values of column 3&4

(Note that you should not use "highlight entire row" for the selection, because it will hide the background colors)

 

altenbach_0-1686440520224.png

 

Message 2 of 6
(1,222 Views)

And if you rather want the whole row affected you would use -2 as column index. -1 is the row header. Same applies for selecting entire columns.

Rolf Kalbermatter
My Blog
Message 3 of 6
(1,174 Views)

Yes, I already showed how to set the entire table to white background color using -2,-2.

 

A problem with the background color is that the selection color goes over it, so you cannot see the background color of the selected cell.

On way around it would be to play with font colors instead, for example as follows:

 

altenbach_0-1686496868842.png

 

0 Kudos
Message 4 of 6
(1,144 Views)

Also note that if this listbox is huge and you do a lot of color changes, all these repeated property calls will tax the UI thread so you might want to defer panel updates for the duration of the FOR loop.

 

In that case, a better option for font or background colors would the "bulk cells" property, where you can do everything at once (font color or background color, or both).

 

Here's how that could look like. Now there is only one property node in the while loop!!

 

altenbach_0-1686498307471.png

 

0 Kudos
Message 5 of 6
(1,140 Views)

On a side note, that "stop button" with the X near the upper right edge is silly! Virtually every window already has an intuitive function for exactly that and everybody already knows how to use it. Simply create a "panel close?" event and discard it, to get the exact same functionality. (We discard it so the window does not actually close, but just goes back to edit mode!)

 

See also my slides 28+ here.

 

altenbach_1-1686500156034.png

 

 

Message 6 of 6
(1,131 Views)