Board index » delphi » String Grid Cell Color

String Grid Cell Color

Would appreciate a suggestion for a way to set the font.color of
different cells, to different colors, at the same time.

______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
   With NINE Servers In California And Texas - The Worlds Uncensored News Source

 

Re:String Grid Cell Color


Quote
<Long Gone> wrote in message

news:tfmi9uk1325dvhhkdgtgl7jvahuia0pluf@4ax.com...

Quote
> Would appreciate a suggestion for a way to set the font.color of
> different cells, to different colors, at the same time.

procedure TForm1.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  strTemp: string;
  Format: integer;
begin
  strTemp := Grid.Cells[ACol,ARow];

  Grid.Canvas.FillRect(Rect);

  if ACol = 0 then
    Format := DT_SINGLELINE or DT_VCENTER or DT_LEFT
  else if ARow = 0 then
    Format := DT_SINGLELINE or DT_VCENTER or DT_CENTER
  else
    Format := DT_SINGLELINE or DT_VCENTER or DT_RIGHT;

  // this is where you decide on colour and text style for the cell
  if (ACol = 0) or (ARow = 0) then
    Grid.Canvas.Font.Style := [fsBold]
  else
    Grid.Canvas.Font.Color := clBlue;

  DrawText(Grid.Canvas.Handle,PChar(strTemp),-1,Rect,Format);

end;

Kevin.

---------------------------------------
ke...@datumsoftware.co.uk
www.datumsoftware.co.uk/shop

Other Threads