LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

text in one cell have different colors

Hello,

I want to achieve the display effect like the picture shows. I can implement it through the 2D Picture control. 

Is there a simple way, such as make the text in the table cell have different colors?

 

Thanks

Henry

 

RGB.png

0 Kudos
Message 1 of 6
(920 Views)

Hi Henry,

 


@henry_2020 wrote:

I want to achieve the display effect like the picture shows. I can implement it through the 2D Picture control. 

Is there a simple way, such as make the text in the table cell have different colors?


I recommend to use a multicolumn listbox to display your data.

In a MCLB you can easily change properties for each "cell"/"row"/"column", including text colors…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(911 Views)

Hi GerdW,

 

Thanks for your quick reply.

I want text in one cell have different colors. Can multicolumn do this? 

 

Thanks

Henry

0 Kudos
Message 3 of 6
(885 Views)

Hi Henry,

 


@henry_2020 wrote:

I want text in one cell have different colors. Can multicolumn do this? 


From your image it looks like each column has its own text color, so the MCLB would be fine…

 

Example:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(870 Views)

@GerdW wrote:

Hi Henry,

 


@henry_2020 wrote:

I want text in one cell have different colors. Can multicolumn do this? 


From your image it looks like each column has its own text color, so the MCLB would be fine…



 

No, in the original image, each cell has multiple text colors and in your example we don't get the lines separating the parent cells clearly. It might be good enough for the OP, but it's not a single cell.

 

I don't think this can be done in the LV controls using the standard properties.

 

A couple of potential options (besides the picture control you already have) might be to use a .NET DataGridView (where at the very least you should be able to override the drawing code and draw everything in the cell yourself) or an embedded Excel spreadsheet (which would require having Excel installed). Both of which would require adding a bunch of code.

 

Another option might be to use a 2D array of picture controls instead of a single picture control, so at least the code would probably be simple.

 

The simplest option in terms of code might be to use a 2D array of strings. If the lengths are fixed, as shown in the original example, then I think that having the same property for all the elements of the array will work OK, but I haven't checked specifically for this. I know that coloring sections of the string can sometimes behave in weird ways.


___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(810 Views)

@tst wrote:

Another option might be to use a 2D array of picture controls instead of a single picture control, so at least the code would probably be simple.


There are numerous other options.

 

Using 2 MCLB's. The top most with the text and no lines, the bottom with merged cells and lines. As long as they don't scroll or resize, it should loo the same as one.

 

Of course, you might as well put a MCLB over a picture control.

 

If you do want to resize, you'd have to resize all the elements.

 

If you do want to scroll, you'd best of adding a custom scrollbar control, and catching it's events.

 

This can all be put in separate code, with the UI living in a subpanel or an XControl.

 

Since the code is now separated completely, you can even put 2000 free labels on your front panel, and manage (recycling them to only show visible cells) their positions, values, colors, etc.. If you put a transparent MCLS on top, you can make it look like your goal.

 

If the cells need to be editable, you can also use string controls.

 

The sky is the limit, really. It's just a matter of what you want exactly, and how much time you're willing to spend on it.

 

Proof of principle (with a lot of work to do):

 

wiebeCARYA_0-1692623178968.png

Result:

wiebeCARYA_1-1692623206336.png

 

0 Kudos
Message 6 of 6
(797 Views)