The reason it works when you do this from code is because you are replacing a pointer to an event handler, regardless of what happened before.
During development, I have two possible places to install the handler. Suppose I have Frame1 in Unit1, and I put it in MyForm in MyUnit, I will be able to set an event handler in both places.
In your case, you want to set the event handler in the frame itself (Unit1 in my example), since the code it refers to is in the frame itself. If you do this, it should work. If you install an event handler in the place where it is used (MyUnit), then an event handler will be assigned to it.
Delphi is smart enough to still call the event handler from your frame while this event handler was assigned before you added it to the form. If you first added it to the form, and then added a handler to the frame, then there will be no frame. Even worse, if you delete the handler in the form, it will still not name the one that is in the form.
What you need to do is:
Right-click your form and select View As Text. Scroll down to the frame. It should be something like:
inline FrameX: fraVehicleUnitFrame1
Under it, find
inherited cmdNewOwner: TButton
There you should see something like:
OnClick = FormOldClickHandler
or maybe
OnClick = nil
Delete this OnClick assignment, review the form again and save. Everything should be fine. If now you select a button (or something like cmdNewOwner) on the form, the object inspector should not show anything next to this event.
source share