我从 TClientdataset 派生并尝试定义一个“始终运行”的 AfterPost 事件。我尝试在构造函数中分配我的 AfterPost 事件,但派生组件似乎没有拾取它
TMyClientDataset = class(TClientDataset)
private
FInserting: Boolean; //set to True at the MyOnNewRecord event
property FuserAfterPost: TDataSetNotifyEvent;
...
public
constructor Create(AOwner: TComponent);
...
implementation
constructor TMyClientDataset.Create(AOwner: TComponent)
begin
...
if Assigned(AfterPost) then
FuserAfterPost := AfterPost;
Afterpost := MyAfterPost;
...
end;
procedure TMyClientDataset.MyAfterPost(Dataset: TDataset);
begin
If Assigned(FuserAfterPost) then
FuserAfterPost(Dataset);
FInserting := False;
end;
我正在尝试做的事情:在新记录中,设置Finserting := True
;在 post 之后,运行用户提供的 OnAfterPost 并设置FInserting := False
;但是 MyAfterpost 事件甚至不会运行。我假设构造函数不是正确的地方AfterPost := MyAfterPost;
吗?它应该去哪里?