Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Gráficos (https://www.clubdelphi.com/foros/forumdisplay.php?f=8)
-   -   cambiar de color CIERTOS renglones en un DBGRID (https://www.clubdelphi.com/foros/showthread.php?t=57977)

advancexz 03-07-2008 19:14:31

cambiar de color CIERTOS renglones en un DBGRID
 
en un DBGRID como puedo cambiar el color ya sea de la letra o del fondo del renglon, en ciertos registros que cumplan con una condicion??

coso 03-07-2008 20:25:22

Hola, debes usar el evento OnDrawCell o OnDrawColumnCell

Código Delphi [-]

procedure T_lfact.DBGrid1DrawColumnCell(Sender : TObject; const Rect : TRect;
     DataCol : Integer; Column : TColumn; State : TGridDrawState);
var
    md,ms : integer;
begin
     if Column.Field = nil then begin inherited; exit; end;

     if condicion then
     begin
          inherited;
          DBGrid1.Canvas.Brush.Color := clRed;
          DBGrid1.Canvas.FillRect(Rect);
     end;

     md := Rect.Left + ((Rect.Right - Rect.Left) div 2) -
          (DBGrid1.Canvas.TextWidth(data) div 2);
     ms := Rect.Top + ((Rect.Bottom - Rect.top) div 2) -
          (DBGrid1.Canvas.TextHeight(data) div 2);
     DBGrid1.Canvas.TextOut(md, ms, data);
end;

Caro 04-07-2008 07:10:33

Hola advancexz, revisa también este hilo http://www.clubdelphi.com/foros/show...ghlight=DBGrid

Saluditos


La franja horaria es GMT +2. Ahora son las 18:19:38.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi