事件传递 [英] Event passsing

查看:65
本文介绍了事件传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个主表单,其中包含一个包含子表单的面板。所以

层次结构如下; frmMain-> MyPanel-> frmChild


主表单上有一个工具栏。当用户按下

工具栏上的按钮时,如何将事件传递给子表单?


进一步说,是否可以使它成为通用的,以便将事件传递给/ b $ b到任何子窗体(frmchild1,frmchild2,......等等),该窗体目前在

面板中打开?


一些代码示例将不胜感激。


谢谢


问候

Hi

I have a main form which contains a panel which contains a child form. So
the hierarchy is as follows; frmMain->MyPanel-> frmChild

I have a toolbar on the main form. When a user presses a button on the
toolbar, how can I pass on the event to the child form?

Taking it further, is it possible to make it generic so that event is passed
to any child form (frmchild1, frmchild2,... so on) that is currently open in
the panel?

Some code examples would be appreciated.

Thanks

Regards

推荐答案

" John" <乔** @ nospam.infovis.co.uk> schrieb
"John" <jo**@nospam.infovis.co.uk> schrieb
我有一个主窗体,其中包含一个包含子窗体的面板。层次结构如下; frmMain-> MyPanel-> frmChild

主表单上有一个工具栏。当用户按下工具栏上的按钮时,如何将事件传递给子表单?


获得click事件后,请调用子表单的方法。孩子

表单不需要听工具栏的事件。

进一步说,是否可以使它成为通用的,以便事件是<传递给当前在面板中打开的任何子窗体(frmchild1,frmchild2,...等等)?


将子表单添加到数组/ arraylist / coolection并在循环中调用上面提到的方法



代码示例将不胜感激。
I have a main form which contains a panel which contains a child
form. So the hierarchy is as follows; frmMain->MyPanel-> frmChild

I have a toolbar on the main form. When a user presses a button on
the toolbar, how can I pass on the event to the child form?
When you get the click event, call a method of the child form. The child
form doesn''t need to listen to the toolbar''s events.
Taking it further, is it possible to make it generic so that event is
passed to any child form (frmchild1, frmchild2,... so on) that is
currently open in the panel?
Add the child forms to an array/arraylist/coolection and call the method
mentioned above in a loop.
Some code examples would be appreciated.



-

Armin


--
Armin




" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

新闻:uI ************** @ TK2MSFTNGP11.phx.gbl ...

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...

你得到click事件,调用子窗体的方法。孩子
形式不需要听工具栏的事件。


会是这样吗?调用frmMain.mypanel.frmchild.mymethod()?

将子表单添加到数组/ arraylist / coolection并在循环中调用上面提到的方法。

When you get the click event, call a method of the child form. The child
form doesn''t need to listen to the toolbar''s events.
Would it be like this; call frmMain.mypanel.frmchild.mymethod() ?

Add the child forms to an array/arraylist/coolection and call the method
mentioned above in a loop.




任何时候面板中只有一个子表单。是否有一个

通用的方法来获得所有的儿童形式?例如;


MyPanl。< childref?> .mymethod()?


谢谢


问候




There would be only one child form in the panel at any one time. Is there a
generic way to get whatever child form there is? Such as;

MyPanl.<childref?>.mymethod()?

Thanks

Regards



" John" <乔** @ nospam.infovis.co.uk> schrieb
"John" <jo**@nospam.infovis.co.uk> schrieb
当您获得click事件时,请调用子表单的方法。
子表格不需要听工具栏的事件。
When you get the click event, call a method of the child form. The
child form doesn''t need to listen to the toolbar''s events.



会不会是这样的;调用frmMain.mypanel.frmchild.mymethod()?



Would it be like this; call frmMain.mypanel.frmchild.mymethod() ?




您写道工具栏在主窗体上。我想ButtonClick

事件也在主窗体中处理。如果frmChild是面板的公共财产,那么你可以写一下


Me.mypanel.frmchild.mymethod


如果您在主表单中引用了子表单,并且如果它是名为frmChild的
,则可以写入


Me.frmChild .mymethod



You wrote that the toolbar is on the main form. I guess the ButtonClick
event is also handled in the main form. If frmChild is a public property of
the panel, you can write

Me.mypanel.frmchild.mymethod

If you have a reference to the child form in the main form, and if it is
called frmChild, then you can write

Me.frmChild.mymethod

将子表单添加到数组/ arraylist / coolection并在循环中调用上面提到的
方法。
Add the child forms to an array/arraylist/coolection and call the
method mentioned above in a loop.



任何时候面板中只有一个子表单。是否有一种通用的方式来获得所有的儿童形式?例如;

MyPanl。< childref?> .mymethod()?



There would be only one child form in the panel at any one time. Is
there a generic way to get whatever child form there is? Such as;

MyPanl.<childref?>.mymethod()?




你写过frmChild1,frmChild2,...你现在说这些是

不同的Form类型?你在哪里对孩子抱怨?怎么回事?
宣布了?


对不起,在找到合适的解决方案之前,我首先要问一些问题。

-

Armin



You wrote frmChild1, frmChild2, ... You are now saying that these are
different Form types? Where do you hold the refrence to the child? How is it
declared?

Sorry, I first have to ask some questions before finding the right solution.
--
Armin


这篇关于事件传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆