exemplo:
OBS: voce deve mudar o código para a sua necessidade
CODE
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; Col, Row:Longint;Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row:Longint;Rect: TRect; State: TGridDrawState);
{***}
procedure DrawCellText;
var
Text: array[0..255] of Char;
begin
StrPCopy( Text, StringGrid1.Cells[ Col, Row ] );
ExtTextOut( StringGrid1.Canvas.Handle, Rect.Left + 2, Rect.Top + 2,
ETO_CLIPPED or ETO_OPAQUE, @Rect, Text, StrLen( Text ),
nil );
end;
{***}
procedure DrawCellColor( CorFundo, CorLetra : TColor );
var
S1, S2 : TColor;
begin
with StringGrid1.Canvas do
begin
S1 := Brush.Color;
S2 := Font.Color;
try
{pinta o fundo com a cor desejada}
Brush.Color := CorFundo;
FillRect( Rect );
{pinta as letras com a cor desejada}
Font.Color := CorLetra;
DrawCellText;
finally
{restaura as cores}
Brush.Color := S1;
Font.Color := S2;
end;{try}
end;{with}
end;
{***}
begin
if ( Row = 2 ) and ( Col = 3 ) then
DrawCellColor( clYellow, clWindowText );
end;
end.
abraço