if qryformx.Active then
qryformx.Close;
qryformx.createdataset;
qryformx.Open;
qryformx.AddIndex('qryformxIndex1','pzh;bm;mc;ybbm;ybmc;sglxbm;sglx;sgysbm;sgys',[],'', '',9);
{ 给数据集指定此索引 }
qryformx.IndexName := 'qryformxIndex1';
qryformx.Close;
with TAggregateField.Create(Self) do begin
FieldName := 'pricesum';
Expression := 'Sum(price)';
IndexName := 'qryformxIndex1';
GroupingLevel := 9;
Active := True;
OnGetText := qryformxpricesumGetText;
DataSet := qryformx;
end;
qryformx.open;
qryformx.AggregatesActive := True;
procedure TForm1.qryformxpricesumGetText(Sender: TField; var Text: string; DisplayText: Boolean);begin if gbLast in ClientDataSet1.GetGroupState(2) then Text := Sender.AsString else Text := '';end;
本文转自鹅倌51CTO博客,原文链接:http://blog.51cto.com/kaixinbuliao/1670210 ,如需转载请自行联系原作者