Hallo Holger,
wenn ich Dich richtig verstehe, willst Du auf den aktuellen Datensatz abgleichen...?
Ich habe mal einen alten Auszug von mir herausgekramt:
Delphi-Quellcode:
procedure TFormAw.DBGridSchuldnerDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
var FaelligFlag:Boolean;
begin
if (Sender is TDBGrid) then with (Sender as TDBGrid) do begin
FaelligFlag:=False;
if Assigned(Column.Field) then begin
if (Column.Field.DataSet.FindField('Faellig')<>nil) then begin
FaelligFlag:=(((Column.Field.DataSet.FieldByName('Faellig').AsDateTime<=Date) or (Column.Field.DataSet.FieldByName('Faellig').AsString='31.12.9999')) and (Column.Field.DataSet.FieldByName('Faellig').AsString<>''));
end;
end;
if (not FaelligFlag) then begin
Canvas.Font.Color:=clSilver;
if (Copy(Column.Title.Caption,1,3)='OFF') then begin
if (Column.Title.Caption='OFFBETR') then Canvas.Font.Style:=[fsBold];
if (Column.Field.DataSet.FieldByName(Column.Title.Caption).AsFloat<0) then Canvas.Font.Color:=clGreen;
end;
if (Canvas.Brush.Color=clHighlight) then Canvas.Brush.Color:=$00FEF8F5;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end
else begin
Canvas.Font.Color:=clBlack;
if (Column.Title.Caption='FAELLIG') then Canvas.Brush.Color:=$00B3B3FF;
if (Copy(Column.Title.Caption,1,3)='OFF') then begin
if (Column.Title.Caption='OFFBETR') then Canvas.Font.Style:=[fsBold];
if (Column.Field.DataSet.FieldByName(Column.Title.Caption).AsFloat<0) then Canvas.Font.Color:=clGreen
else
if (Column.Field.DataSet.FieldByName(Column.Title.Caption).AsFloat>0) then Canvas.Font.Color:=clRed;
end;
if (Canvas.Brush.Color=clHighlight) then Canvas.Brush.Color:=$00FEF8F5
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
end;
end;
Ich bin nicht ganz sicher, aber vielleicht musst Du über Column.Field.DataSet.FieldByName(xxx) auf Deine Zellenwerte abgleichen.
Stahli