Delphi 组件动态分配事件
我的表单上有一个 ADOStoredProc。它不是可视的,而是在代码中。通常,如果组件是可视的,则处理事件非常容易。只需双击所需的事件即可。但我如何用代码来做到这一点。我已经声明了一个过程:
procedure SP_SearchAfterScroll(DataSet:TDataSet)
现在如何将 SP_Search(这是 ADOStoredProc)AfterScroll 事件处理程序属性分配给我上面编写的过程。我确信你会回答它。所以提前致谢。
I have an ADOStoredProc on my form. It's not visual but in code.Normally it's pretty easy to handle an event if a component is visual.It's just a matter of double clicking the desired event. But how do I do it with code.I've declared a procedure:
procedure SP_SearchAfterScroll(DataSet:TDataSet)
Now how do I assign SP_Search(this is the ADOStoredProc) AfterScroll event handler property to the procedure I wrote above. I'm sure you're going to answer it. So thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当 SP_Search 是 TAdoStoredProc 并且具有 OnAfterScroll 属性时,您需要做的就是:
我假设您为 SP_SearchAfterScroll 使用了正确的签名。也就是说,OnAfterScroll 属性的类型如下所示:
如果 OnAfterScroll 属性的类型与此不同,则需要确保 SP_SearchAfterScroll 过程与该类型中的参数匹配。
编辑
在 Mikayil 提出的评论中
我还没来得及回答这个问题,同时 Mikey 解释得很好,所以为了(更容易)将来参考,我将他的解释放在这里:
When SP_Search is the TAdoStoredProc and has an OnAfterScroll property, all you need to do is:
I am assuming that you used the correct signature for SP_SearchAfterScroll. That is to say that the OnAfterScroll property has a type looks like:
If the OnAfterScroll property has a type that differs from this, you will need to make sure that your SP_SearchAfterScroll procedure matches the parameters in that type.
Edit
In the comments Mikayil asked
I hadn't gotten round to answering that and in the mean time Mikey explained it very well, so for (easier) future reference I am including his explanation up here:
声明为:
TDataSetNotifyEvent
Declare as:
TDataSetNotifyEvent