//muda a cor somente da célula
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (Column.Field.FieldName = 'Pago') then
begin
if table1.FieldByName('pago').AsString = 'sim' then
begin
dbgrid1.Canvas.Font.Color := clBlue;
dbgrid1.Canvas.Font.Style :=[fsBold];
dbgrid1.Canvas.FillRect(Rect);
dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end
else
begin
dbgrid1.Canvas.Font.Color:= clRed;
dbgrid1.Canvas.FillRect(Rect);
dbgrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
end;
//muda a cor de toda a linha
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if table1.FieldByName('pago').AsString = 'sim' then
begin
dbgrid1.Canvas.Font.Color := clBlue;
dbgrid1.Canvas.Font.Style :=[fsBold];
dbgrid1.Canvas.FillRect(Rect);
dbgrid1.DefaultDrawDataCell(Rect,Field,State);
end
else
begin
dbgrid1.Canvas.Font.Color:= clRed;
dbgrid1.Canvas.FillRect(Rect);
dbgrid1.DefaultDrawDataCell(Rect,Field,State);
end;
end;
Assinar:
Postar comentários (Atom)
6 comentários:
onde consigo o TFiled
na uses do form digita
DB;
Por favor quem é esse " table1 ", não consigo entender esse cara ai pois sou iniciante. obrigado e que DEUS os abençoe...
José, o table1 vc troca pelo nome da sua tabela. Digamos que vc está alterando o dbGrid de uma tabela chamada Pagamentos. Vc troca o table1 pelo PAGAMENTOS
12Estou tendo esse erro,
E2005 'TField' is not a type identifier.
erro em identificar o TField. o como eu resolvo isso?
12Estou tendo esse erro,
E2005 'TField' is not a type identifier.
erro em identificar o TField. o como eu resolvo isso?
Postar um comentário