TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
-
acarlomagno
- Newbie
- Posts: 4
- Joined: Tue May 30, 2017 12:00 am
Post
by acarlomagno » Wed Feb 21, 2018 2:54 pm
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;
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Feb 27, 2018 11:51 am
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;
-
acarlomagno
- Newbie
- Posts: 4
- Joined: Tue May 30, 2017 12:00 am
Post
by acarlomagno » Tue Feb 27, 2018 12:04 pm
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
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Wed Feb 28, 2018 7:40 am
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.
-
acarlomagno
- Newbie
- Posts: 4
- Joined: Tue May 30, 2017 12:00 am
Post
by acarlomagno » Wed Feb 28, 2018 2:24 pm
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
-
Attachments
-
- Schermata 2018-02-28 alle 15.23.08.png (12.08 KiB) Viewed 23649 times
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Mon Mar 05, 2018 12:32 pm
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
-
acarlomagno
- Newbie
- Posts: 4
- Joined: Tue May 30, 2017 12:00 am
Post
by acarlomagno » Mon Mar 05, 2018 4:32 pm
Hi,
ok with TAlphacolors.yellow .. it correct
mah ... I am going crazy
thanks for support!
Antonello
-
Yeray
- Site Admin
- Posts: 9614
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Mar 06, 2018 7:16 am
Hello Antonello,
acarlomagno wrote:I am going crazy
+1
acarlomagno wrote:thanks for support!
Thanks for the gratitude!