Page 1 of 1

Cell Coloring

Posted: Wed Dec 13, 2017 3:40 pm
by 18682546
The getting started documentation alludes to individual cell coloring but doesn't give any code specifics. How do I change the color of a specific cell using Delphi?

Re: Cell Coloring

Posted: Thu Dec 14, 2017 10:39 am
by yeray
Hello,

You can use the column OnPaint event as follows:

Code: Select all

  TeeGrid1.Columns[2].OnPaint:=GridOnPaintColumn;

Code: Select all

procedure TFormGridDataset.GridOnPaintColumn(const Sender:TColumn; var AData:TRenderData; var DefaultPaint:Boolean);
begin
  if AData.Row=1 then
    with (Sender.Render as TTextRender) do
    begin
      Format.Brush.Visible:=True;
      Format.Brush.Color:=clRed;

      Paint(AData);
    end
  else
    DefaultPaint:=True;
end;