Reputation: 7438
If I'm searching a component like this :
TMemo(FindComponent('mymemoname'));
How do I call the OnChange
event of this TMemo
? The example below won't work :
TMemo(FindComponent('mymemoname')).Change();
Thanks
Upvotes: 1
Views: 388
Reputation: 597205
The Change()
method is protected
, so to call it directly like you are trying to, you would need to use an accessor class to grant access to the calling scope, eg:
type
TMemoAccess = class(TMemo)
end;
TMemoAccess(TMemo(FindComponent('mymemoname'))).Change();
Otherwise, you can just call the OnChange
handler directly instead:
var TheMemo := TMemo(FindComponent('mymemoname'));
TheMemo.OnChange(TheMemo);
Upvotes: 6