08-18-2023 01:44 AM
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
08-18-2023 01:57 AM
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…
08-18-2023 03:02 AM
Hi GerdW,
Thanks for your quick reply.
I want text in one cell have different colors. Can multicolumn do this?
Thanks
Henry
08-18-2023 03:45 AM - edited 08-18-2023 03:55 AM
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:
08-21-2023 03:47 AM
@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.
08-21-2023 07:56 AM - edited 08-21-2023 08:07 AM
@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):
Result: