LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set colors in multicolumn listbox's cells?

In one version of LV with 64K in the list box, it made difference.

 

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 11 of 24
(4,852 Views)

Believe me, I would love to find a funky workaround for this one 😉

0 Kudos
Message 12 of 24
(4,850 Views)

How do you set the entire row to a background color?  I've got an event (in an event structure) that is active when you double click on a row, I use the "Point to Row Column" property to identify the cell position of the cell clicked, then I use the MCListbox> Active cell to set that cell to be active then I set the cellBG to the color I desire. 

 

I have several problems with this.  (1) I want the entire row to be highlighted not just the cell. and (2) when new items are added to the list box, the colored cell stays the same and doesn't move down with the associated data. For example if I double click on the 3rd cell down to highlight it, after I add more data to the list box, the 3rd cell always is highlighted and doesn't move down with the specific data I wanted highlighted.

 

Any help?

0 Kudos
Message 13 of 24
(4,783 Views)

Let me try to re-iterate your problem so that I am sure I understand what you are asking.

 

1.) During execution you double click on one cell in the listbox and are able to change that cell to a different color.  You also want to change the background color of every cell.

 

- Use a for loop to cycle through every element in the one particular row and change the each color.

 

2.) During execution you dynamically add more data to the list, but the colors do not follow.  You would like the same data, not the same row, to remain highlighted.  I will assume you only want one row highlighted at a time.

 

- Use a shift register to keep track of which row is the colored row.  When you add a new row, check to see if the row is above or below your colored row.  If the new row is below, do nothing.  If the new row is above, first color the background of the old row to white, then paint the new location a different color.

 

Let us know if this works!

 

Ryan

Applications Engineer

National Instruments

ni.com/support

0 Kudos
Message 14 of 24
(4,754 Views)

HI - thanks for the tip on using a for loop to cycle through all of the cells in a row to highlight them too.

 

for (2) your understanding is correct, however, I need multiple rows of data to be highlighted at the same time.

0 Kudos
Message 15 of 24
(4,751 Views)

In that case, I would expand upon the idea.  The output from the Multilist indicator is an array of the selected rows, so I instead of keeping track of the previous selected column, keep track of the array.  Then in your event handler for the input row even, have another for-loop that will check each entry to see if it is above or below the new entry, and then color and un-color appropriately.

 

Depending on how many rows you have selected and how many columns each row has, it may be advantageous to check and see if any row is already colored, so that you do not need to un-color and re-color.  I would get the basic implementation working first, and then if you find it to be to slow, then focus on optimizing your implementation.

 

Let us know how it goes!

 

Ryan

Applications Engineering

National Instruments

ni.com/support

Applications Engineer
National Instruments
0 Kudos
Message 16 of 24
(4,751 Views)

Three additional points:

 

  1. You can use the value -2 to color an entire row or column in a single call (e.g. 5,-2 will select the entire 6th row as active) and this should appear in the help for the active cell property. You can also use it to clear the table's colors.
  2. When doing a series of updates, it's highly recommended to use the Defer Panel Updates property before and after the updates so that they all happen together.
  3. If I understand Ryan correctly, this is basically the same as his suggestion - Don't use the list box to keep track of the color data. Instead, have additional arrays which will have a record of the data and the colors and use the data from those array to fill and color the list box in a separate event. That means that when you add data to the data array, you immediately add parallel data to the color array. Here's a gross simplification:
    MC_LB.png

    In the update event, you defer updates, clear the table's colors and then use the data in the cluster to write both the data and the colors to the list box, then undefer updates.

    Like I said, this is a simplified example and there may be much better ways of representing the data you need.

___________________
Try to take over the world!
Message 17 of 24
(4,743 Views)

Not sure if anyone will see this...but it really blows my mind that there isn't a direct way to just set an individual cell color with a row/column input and thats it.

 

0 Kudos
Message 18 of 24
(1,538 Views)

Hi Coastal,

 


@CoastalLabVIEWER wrote:

Not sure if anyone will see this...but it really blows my mind that there isn't a direct way to just set an individual cell color with a row/column input and thats it.

 


It seems you miss the properties of a MCL:

GerdW_0-1676740422373.png

Just select the ActiveCell (which needs row & column), then set its color!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 24
(1,526 Views)

And if you want something that "sets it and that's it", then you can turn the code into a subVI. The documentation for the property node doesn't say if all of its properties are executed atomically, so you should probably assume that they aren't and make sure no other code works on the active cell at the same time.


___________________
Try to take over the world!
0 Kudos
Message 20 of 24
(1,511 Views)