Fórum Cores em uma DBGrid #174372
11/08/2003
0
Galera, como posso colocar cores em determinadas linhas de uma dbGrid, baseado em seu conteúdo?
[]´s
Duilton
[]´s
Duilton
Duilton
Curtir tópico
+ 0
Responder
Posts
11/08/2003
Buosinet
Vc deve usar o evento OnDrawColumnCell da DBGrid. Veja o exemplo abaixo, que pinta a fonte de vermelho caso a data seja superior a 01/01/94:
procedure TForm1.DBGrid1DrawColumnCell1(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Column.FieldName = ´LastInvoiceDate´) then
with DBGrid1.Canvas do begin
if Table1LastInvoiceDate.Value >= EncodeDate(1994,1,1) then
Font.Color := clNavy
else
Font.Color := clRed;
end;
DBGrid1.DefaultDrawDataCell(Rect,Column.Field,State);
end;
procedure TForm1.DBGrid1DrawColumnCell1(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Column.FieldName = ´LastInvoiceDate´) then
with DBGrid1.Canvas do begin
if Table1LastInvoiceDate.Value >= EncodeDate(1994,1,1) then
Font.Color := clNavy
else
Font.Color := clRed;
end;
DBGrid1.DefaultDrawDataCell(Rect,Column.Field,State);
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)