I am developing a DataAware component and executing some code after the database is open.
This is the code I have at the moment:
TMyDataAwareComponent = class(TDataAwareComponent)
private
{ Private declarations }
procedure ToBeExecutedOnAfterOpen(DataSet: TDataSet);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
end;
constructor TMyDataAwareComponent.Create(AOwner: TComponent);
begin
inherited;
if Assigned(Self.DataSource) then
begin
Self.DataSource.DataSet.AfterOpen := ToBeExecutedOnAfterOpen;
end;
end;
procedure TMyDataAwareComponent.ToBeExecutedOnAfterOpen(DataSet: TDataSet);
var
i: Integer;
begin
// Do something here
end;
The code works correctly but the event AfterOpen of the dataset linked to the component is not fired any longer. How can I make sure the AfterOpen Event is fired first in the dataset and then in my component ?
Is there a solution valid for all events in the datasets (BeforeOpen, AfterOpen, BeforeCancel, BeforeDelete, AfterCancel, AfterDelete, ...etc) ?
TDBEditand itsFDataLinkfield; for grid-like components look atTDBGridand itsFDataLinkfield too.