创建"聚合"字段时,不会自动添加TClientDataSet聚合规范

时间:2020-03-05 18:41:58  来源:igfitidea点击:

我需要在TClientDataSet中创建一个Aggregate Field,但正如docs中所述:

Choose OK. The newly defined aggregate
  field is automatically added to the
  client dataset and its Aggregates
  property is automatically updated to
  include the appropriate aggregate
  specification.

当我添加新的聚合字段时,聚合规范未添加到TClientDataSet的聚合中,因此无法使用其OnUpdateMethod。

我还尝试处理新的Aggregate Field的OnChange事件,但根本没有触发它。

难道我做错了什么?我只想拥有一个汇总字段并触发一个事件,它改变了所有值。

这在delphi上坏了吗?因为什么是文档中不反映实际的行为。

编辑:
@米歇尔·斯纳德(Michal Sznajder)
我正在使用Delphi 2007

解决方案

回答

哪个版本的Delphi?我刚刚尝试了干净的D7应用程序,并添加了TAggregateField。

回答

我认为我们可能在TAggregate和TAggregateField对象之间感到困惑,而Delphi文档可能无济于事。

AFAICT会自动"重新计算" TAggregateField对象,并将其绑定到数据感知控件(如TDBText),但没有任何OnUpdate事件。

另一方面," TAggregate"对象确实具有OnUpdate事件,但不能绑定到数据感知控件。

这可能很有启发性:http://dn.codegear.com/article/29272