How can I assign the OnClick event of a ToolButton at runtime?

隐身守侯 提交于 2019-12-01 04:20:00

From the comments it is clear that you are not assigning a TNotifyEvent to the OnClick event. The declaration of TNotifyEvent is:

TNotifyEvent = procedure(Sender: TObject) of object;

So you need a procedure, with a single parameter of type TObject, and the procedure must be the method of an object. So, something like this:

procedure TMyForm.ToolButtonClick(Sender: TObject);

And then you can assign it like so:

NewToolButton.OnClick := ToolButtonClick;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!