Ver Mensaje Individual
  #24  
Antiguo 05-01-2011
Avatar de Aleca
Aleca Aleca is offline
Miembro
 
Registrado: may 2003
Ubicación: Venado Tuerto, Argentina
Posts: 277
Reputación: 22
Aleca Va por buen camino
le estuve dando un poco de vuelta al asunto y se armas un campo calculado que lleve el color en que se va a pintar (0-blanco, 1-Verde) y pintas de acuerdo al valor de ese campo.
Código Delphi [-]
....
  private
    { Private declarations }
    nValorAnt, nColor: Integer;
    FColor, BColor: TColor;
...
procedure TForm1.DBGDatosDrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  if State = [] then
  begin
    if TblArticulosCAMPO_COLOR.AsInteger = 0 then
      begin
        FColor := clWhite;
        BColor := clGreen;
      end
      else
      begin
        FColor := clBlack;
        BColor := clWhite;
      end;
    TDBGrid(Sender).Canvas.Font.Color := FColor;
    TDBGrid(Sender).Canvas.Brush.Color := BColor;
  end
  else
    TDBGrid(Sender).Canvas.Font.Color := clWhite;
  TDBGrid(Sender).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  nValorAnt := 0;
  nColor := 0;
  FColor := clWhite;
  BColor := clGreen;
end;

procedure TForm1.TblArticulosCalcFields(DataSet: TDataSet);
begin
  if nValorAnt <> TblArticulosID_GRUPO.AsInteger then
  begin
    nValorAnt := TblArticulosID_GRUPO.AsInteger;
    if nColor = 0 then
      nColor := 1
    else
      nColor := 0;
  end;
  TblArticulosCAMPO_COLOR.AsInteger := nColor;
end;
end.

ahora me lo mantiene estable.
Saludos
__________________
Aleca
Responder Con Cita