LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the "Selection Color" property of a Listbox for each active row

Solved!
Go to solution

Hi all!

In the attached image you can see the "SelColor" property under "ActiveCell" but the color of the selection changes for every single row.

I was wondering if it's possibile to use the "Selection Color" property of a Multicolumn Listbox for the current active row only.

 

image.png

 

This is an alarms' listbox, I'd like to keep the red color for alarms' selections and the yellow color the warnings' selections.

 

This is the right selection (red selection for the alarm)...This is the right selection (red selection for the alarm)...

 

... And this is the bad one (red selection for the warning instead of yellow selection)... And this is the bad one (red selection for the warning instead of yellow selection)

 

 

Thank you!

0 Kudos
Message 1 of 8
(3,997 Views)

You typically get better help if you would attach a simplified VI instead of pictures.

 

The selection color is whatever is currently selected and not tied to any specific cell. It also depends if the option "highlight entire row" is set. Can you clarify exactly what behavior you want?

0 Kudos
Message 2 of 8
(3,952 Views)

Sorry, no.  The selection color always applies to all cells.

But you could write code that changes it on the fly depending on which row is selected.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 8
(3,936 Views)

Hi! Thanks for the reply.

How can I activate the color change everytime i select a row? Event Structure? Thanks!

0 Kudos
Message 4 of 8
(3,872 Views)
Solution
Accepted by CarfRip

Try something like this:

l1.png

That might be OK, but it might flicker.  If it does, do something like this instead:

l2.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 8
(3,864 Views)

Thanks again for your precious help!

Your example works with single column listbox, I have a multicolumn one but I edited your code and tried it in a separeted VI, it works!

I simply get the color I need from a reference cell in the same row of the selected one and set the selection color.

 

Now the second issue: as you can see in the attached pictures I need to continuously run the "main cycle", which fills the listbox cells, while I check the selected row as you showed me, is there a way to make this work? The VI I attached doesn't work, I also tried to insert the "main cycle" in the "Timeout" case of the event structure but it doesn't work.

 

Immagine.png

 

Thanks!

0 Kudos
Message 6 of 8
(3,855 Views)

@CarfRip wrote:

Thanks again for your precious help!

Your example works with single column listbox, I have a multicolumn one but I edited your code and tried it in a separeted VI, it works!

I simply get the color I need from a reference cell in the same row of the selected one and set the selection color.

 

Now the second issue: as you can see in the attached pictures I need to continuously run the "main cycle", which fills the listbox cells, while I check the selected row as you showed me, is there a way to make this work? The VI I attached doesn't work, I also tried to insert the "main cycle" in the "Timeout" case of the event structure but it doesn't work.

 

Immagine.png

 

Thanks!


It doesn't work as shown because the loop will iterate after everything inside it has finished.  The event structure waits for an event, so it won't finish until an event happens.  When you put the Main Cycle in the timeout case of the event structure, what did you set the timeout to?

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 7 of 8
(3,840 Views)

Poor me... I didn't set the timeout 😪
Now it works like a charm! Thank you so much Paul 😁

0 Kudos
Message 8 of 8
(3,828 Views)