var
Form1: TForm1;
saveprice:Real=-1.00; //设置一初始值
savecolor:Boolean=true;
implementation
{$R *.DFM}
... //画排序的箭头略
procedure TForm1.RxDBGrid1TitleBtnClick(Sender: TObject; ACol: Integer;
Field: TField);
begin
RxQuery1.MacroByName('me').AsString:=Field.FieldName;
if RxQuery1.MacroByName('m2').AsString='' then
RxQuery1.MacroByName('m2').AsString:='desc'
else
RxQuery1.MacroByName('m2').AsString:='';
RxQuery1.close;
RxQuery1.open;
end; //排序
procedure TForm1.RxDBGrid1GetCellParams(Sender: TObject; Field: TField;
AFont: TFont; var Background: TColor; Highlight: Boolean);
begin
if Field.FieldName='Price' then
begin
if (saveprice=-1.00)or(saveprice<>Field.AsFloat) then
begin
saveprice:=field.asfloat;
savecolor:=not savecolor;
end;
if savecolor then Background:=clred else Background:=clblue;
end;
end;