Fabio Gomes
Fabio Gomes

Reputation: 6022

TClientDataSet Aggregates specification aren't added automatically when creating an Aggregate field

I need to create an Aggregate Field in a TClientDataSet, but as said in the 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.

When I add a new aggregate field, the aggregate specification isn't added to the TClientDataSet's Aggregates, therefore I can't use its OnUpdateMethod.

I also tried handling the OnChange event of my new Aggregate Field, but it isn't fired at all.

Am I doing something wrong? I just want to have an aggregated field and fire an event everything it's value change.

Is this broken on delphi? Because what is in the documentation doesn't reflect the actual behavior.

edit: @Michal Sznajder I'm using Delphi 2007

Upvotes: 1

Views: 1521

Answers (2)

Roddy
Roddy

Reputation: 68033

I think you may be getting confused between TAggregate and TAggregateField objects, and the Delphi documentation probably isn't helping.

AFAICT, TAggregateField objects are automatically 'recalculated' and can be bound to data-aware controls like TDBText, but don't have any OnUpdate event.

"TAggregate" objects, on the other hand, do have an OnUpdate event, but can't be bound to data-aware controls.

This may be enlightening: http://dn.codegear.com/article/29272

Upvotes: 4

Michal Sznajder
Michal Sznajder

Reputation: 9406

Which version of Delphi ? I just tried clean D7 application and TAggregateField was added.

Upvotes: 1

Related Questions