1.定义字段
var var Cal:Tfield;
begin
Cal:=tfield.Create(self);
Cal.Name:='Cal';
Cal.SetFieldType(ftFloat);
Cal.FieldKind :=fkCalculated;
ADOQuery1.Fields.Add(Cal);
end;
2.定义事件
procedure TForm1.CalFields(DataSet: TDataSet);
begin
if DataSet.FindField('Cal')<>nil then
begin
//do thing
end;
end;
然后
ADOQuery1.OnCalcFields:= CalFields;