Revisando todos los post se me ocurrio hacer lo siguiente...
Me recorde que cuando en la grilla uno realiza seleccion de registros internamente se utiliza un TList para almacenar los bookmark de los registros seleccionados, debido a eso pense en utilizar un TStrings para almacenar la informacion que se requiere por cada registro.
Este es el resultado, tome el codigo del amigo
duilioisola y le hice algunos cambios...
Código Delphi
[-]
public
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);
if Boolean(List.Objects[index]) then
begin
Canvas.Font.Color := clBlack;
Canvas.Brush.Color := clYellow;
end
else
begin
Canvas.Font.Color := clBlack;
Canvas.Brush.Color := clInfoBk;
end;
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;
begin
Index:=List.IndexOf(DataSet.FieldByName('ASIENTO').AsString);
if Index=-1 then
begin
List.AddObject(DataSet.FieldByName('ASIENTO').AsString, Pointer(Sombra) );
Sombra := not Sombra;
end;
end;
Por supuesto faltan las validaciones...
Saludos cordiales