Advertisement
RibaSoft

Colorir DBGrid

Jan 31st, 2023 (edited)
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.16 KB | None | 0 0
  1. procedure TFormParcelas.DBGridDadosDrawColumnCell(Sender: TObject; const Rect: TRect;
  2.   DataCol: integer; Column: TColumn; State: TGridDrawState);
  3. begin
  4.   if(Column.FieldName = 'TOTAL')then
  5.   begin
  6.     DBGridDados.Canvas.Font.Color := clBlack;
  7.  
  8.     if(Column.Field.AsCurrency > 0) then
  9.     begin
  10.       if(State = [gdSelected])or(State = [gdSelected, gdFocused])then
  11.       begin
  12.         DBGridDados.Canvas.Brush.Color := clRed;
  13.         DBGridDados.Canvas.Font.Color := clWhite;
  14.       end
  15.       else
  16.       begin
  17.          DBGridDados.Canvas.Brush.Color := Riba.VermelhoClaro;
  18.          DBGridDados.Canvas.Font.Color := clBlack;
  19.       end;
  20.     end
  21.     else
  22.     begin
  23.       if(State = [gdSelected])or(State = [gdSelected, gdFocused])then
  24.       begin
  25.         DBGridDados.Canvas.Brush.Color := clGreen;
  26.         DBGridDados.Canvas.Font.Color := clWhite;
  27.       end
  28.       else
  29.       begin
  30.         DBGridDados.Canvas.Brush.Color := Riba.VerdeClaro;
  31.         DBGridDados.Canvas.Font.Color := clBlack;
  32.       end;
  33.     end;
  34.  
  35.     DBGridDados.Canvas.FillRect(Rect); //Aplica as mudanças
  36.     DBGridDados.DefaultDrawColumnCell(Rect,DataCol,Column,State); //Redesenha os dados na coluna
  37.   end;
  38. end;  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement