Aqui incorporando muchos colores...
Código Delphi
[-]
Sombra:Boolean;
List:TStrings;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
index:Integer;
begin
with TDBGrid(Sender) do
begin
if (gdFocused in State) then begin
Canvas.Font.Color := clWhite;
Canvas.Brush.Color := clHighlight;
end
else
begin
Index:=List.IndexOf(DataSource.DataSet.FieldByName('ASIENTO').AsString);
Canvas.Font.Color := clBlack;
Canvas.Brush.Color := TColor(List.Objects[index]);
end;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
List:=TStringList.Create;
Table1.Active:=True;
end;
procedure TForm1.Table1AfterOpen(DataSet: TDataSet);
begin
Sombra := true;
end;
procedure TForm1.Table1CalcFields(DataSet: TDataSet);
var
Index:Integer;
fColor:TColor;
begin
Index:=List.IndexOf(DataSet.FieldByName('ASIENTO').AsString);
if Index=-1 then
begin
fColor:=RGB(Random(205),Random(205),Random(205));
List.AddObject(DataSet.FieldByName('ASIENTO').AsString, Pointer(fColor)); Sombra := not Sombra;
end;
end;