Re: coloured text in stringgrid

Posted by Johan p14205 on July 19, 2007

In Reply to Re: coloured text in stringgrid posted by Coxy on July 19, 2007

: Thanks for the help and quick reply Johan.
: I've managed to get different coloured text in a cell now, but something weird is going on.

: I've put this:
: font.Color:=clgreen;
: TextOut(rect.left+2,rect.Top+2,stringgrid1.cells[acol,arow]);

: in a case statement, but some of the cells have black strings in them!? (sometimes next to the green one, sometimes on their own). But the cells are not written to anywhere else...

: I also noticed that if you offset the characters a bit more (e.g. rect.left+5) that there is another character "underneath" which is black.

: Strange. Any ideas?

If there are black strings on their own: might be that your Case statement doesn't deal with *all* possibilities :)

Black strings next to green strings: has to do with the offset. Here's why:

The stringgrid automatically writes the contents of a cell at Rect.Left + 2 in black. Afterwards, the OnDrawCell event comes and you overwrite the cell in green. Therefore, if you offset by more than Rect.Left + 2, the black text stays partially visible "underneath".

Related articles


Follow Ups