Delphi 中的 VB [(Function) 句柄 ...] 等效项
假设我们有类似的东西
Private Sub ClickObject(ByVal sender As System.Object, ByVal e as System.Eventargs)
Handles Object1.click, Object2.click, Object3.click
,它在“句柄”之后获取事件并将它们发送到函数。
Delphi 中有类似的东西吗?我该怎么做?
Say we had something like
Private Sub ClickObject(ByVal sender As System.Object, ByVal e as System.Eventargs)
Handles Object1.click, Object2.click, Object3.click
Which takes the event after the 'Handles' and sends them to the function.
Is there an equivalent for this in Delphi, and how would I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
TActionList
添加到您的表单中。向其中添加TAction
并像处理其他控件的OnClick
事件一样处理其OnExecute
事件。指定控件的Action
属性以引用您添加到操作列表中的操作。 (这也会导致控件从关联的操作中获取其标题以及启用和可见属性。这意味着当菜单和工具栏按钮表示相同的命令时,可以更轻松地使它们具有统一的状态。)Add a
TActionList
to your form. Add aTAction
to it and handle itsOnExecute
event as you would theOnClick
event of some other control. Assign theAction
properties of the controls to refer to the action you added to the action list. (This also causes the controls to acquire their captions and enabled and visible properties from the associated action. It's meant to make it easier to have menus and toolbar buttons have uniform states when they represent the same command.)是的。
您可以创建一个事件处理程序并将其分配给多个控件。
Yes.
You can create an event handler and assign it to multiple controls.