Page 1 of 1

Cell custom font color

Posted: Wed Feb 21, 2018 2:54 pm
by 16481034
Hello,
I would to change a font color of a cell of TeeGrid on Firemonkey (win32 and OSX)

I tried the onPaint event of column with this code but change only background of cell, why?

thanks
Antonello

Code: Select all

procedure TFormGridDataSet.GridOnPaintColumn(const Sender: TColumn;
  var AData: TRenderData; var DefaultPaint: Boolean);
begin

  with (Sender.Render as TTextRender) do
  begin
    Format.Brush.Visible := True;
    Format.Brush.Color := $FF0000FF;

    Format.Font.Color := $FF00FF00;

    Paint(AData);
  end;
end;

Re: Cell custom font color

Posted: Tue Feb 27, 2018 11:51 am
by yeray
Hello,

Try like this:

Code: Select all

procedure TStringGridForm.PaintText(const Sender:TColumn; var AData:TRenderData; var DefaultPaint:Boolean);
begin
  DefaultPaint:=True;

  if AData.Row=4 then
  begin
    DefaultPaint:=False;

    AData.Painter.SetFontColor(clRed);
    (Sender.Render as TTextRender).Paint(AData);
    AData.Painter.SetFontColor(clBlack);
  end;
end;

Re: Cell custom font color

Posted: Tue Feb 27, 2018 12:04 pm
by 16481034
Yeray wrote:Hello,

Try like this:

Code: Select all

procedure TStringGridForm.PaintText(const Sender:TColumn; var AData:TRenderData; var DefaultPaint:Boolean);
begin
  DefaultPaint:=True;

  if AData.Row=4 then
  begin
    DefaultPaint:=False;

    AData.Painter.SetFontColor(clRed);
    (Sender.Render as TTextRender).Paint(AData);
    AData.Painter.SetFontColor(clBlack);
  end;
end;
Hello,

the PaintText procedure is not a TeeGrid event, I must assigne manually to onPaint event?

and I saw if I use a TAlphacolors.RED ... I see the BLUE color ... why?

regards
Antonello

Re: Cell custom font color

Posted: Wed Feb 28, 2018 7:40 am
by yeray
Hello Antonello,

Indeed, the PaintText procedure has to be assigned to an OnPaint event.
Ie:

Code: Select all

TeeGrid1.Columns[2].OnPaint:=PaintText;
I tested this with the TeeGrid as TStringGrid example.

Re: Cell custom font color

Posted: Wed Feb 28, 2018 2:24 pm
by 16481034
Hi,
yes now works, but the colors are wrong!

AData.Painter.SetFontColor( TColors.Yellow );

I set Tcolors.yellow ... and I have the color "light blue"

see the attachment

Antonello

Re: Cell custom font color

Posted: Mon Mar 05, 2018 12:32 pm
by yeray
Hello,

Sorry, I was testing it in VCL, not in FMX.
It gives me a light blue when I use TColors.Yellow in Firemonkey, but it gives me yellow when I use TAlphaColors.Yellow.
http://docwiki.embarcadero.com/RADStudi ... FireMonkey

Re: Cell custom font color

Posted: Mon Mar 05, 2018 4:32 pm
by 16481034
Hi,
ok with TAlphacolors.yellow .. it correct

mah ... I am going crazy ;-)

thanks for support!

Antonello

Re: Cell custom font color

Posted: Tue Mar 06, 2018 7:16 am
by yeray
Hello Antonello,
acarlomagno wrote:I am going crazy ;-)
+1
acarlomagno wrote:thanks for support!
Thanks for the gratitude!