Ver Mensaje Individual
  #6  
Antiguo 22-02-2008
Avatar de gluglu
[gluglu] gluglu is offline
Miembro Premium
 
Registrado: sep 2004
Ubicación: Málaga - España
Posts: 1.455
Reputación: 21
gluglu Va por buen camino
Este tema ya ha sido tratado en múltiples ocasiones en los foros.

Seguro que utilizando la búsqueda encontrarías muchas referencias. No obstante, para que veas que en Delphi 'siempre' se puede, te invito a utilizar el siguiente código :

Código Delphi [-]
procedure TForm.DBGrid1DrawColumnCell(Sender: TObject;
  Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
 
  If (Column.Index = 5) and (Column.Field.Dataset.FieldbyName('SALDO').AsFloat < 0) and (not DataSet.IsEmpty) then begin
    if gdFocused in State then begin
      DBGrid1.Canvas.Brush.Color := clBlue    // Color que quieras que tenga el fondo si la línea tiene foco
      DBGrid1.Canvas.Font.Color  := clWhite   // Color del Font que quieras que tenga si la línea tiene foco
    end
    else begin
      DBGrid1.Canvas.Brush.Color := clRed;    // Color que quieras que tenga si la línea NO tiene foco
      DBGrid1.Canvas.Font.Color  := clWhite   // Color del Font que quieras que tenga si la línea NO tiene foco
    end;
  end;
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
 
end;

Siendo Column.Index = al número de columna que quieras colorear. También podrías hacer referencia a dicha columna por el campo que se encuentra en ella.

DataSet es el DataSet asociado a tu DBGrid.

... y nunca desesperes si algo no te funciona
__________________
Piensa siempre en positivo !

Última edición por gluglu fecha: 22-02-2008 a las 12:03:04.
Responder Con Cita