如何调用从父窗体用户窗体的方法? [英] How do I invoke a method in a userform from parent form?
问题描述
学习C#:
我有一个结构
form1 (splitcontainer)
userformLeft (button + sub-panel)
userformDisplay (loaded into panel in userformLeft)
userformRight
我想在userformDisplay从Form1中(定时器在Form1)执行的方法。
I want to execute a method in userformDisplay from form1 (timer in form1).
和周围的其他方式,让我们说我有公共财产form1.mainTimer,可以 我把它从userFormDisplay像
And the other way around, let's say I have public property form1.mainTimer, can I call it from userFormDisplay like
myLong = this.parent.parent.mainTimer;
或类似的。
推荐答案
一种形式和另...之间进行通信的类似的问题是否附着到事件之一,或呼叫/设定值向/从彼此。这里有几个链接的问题我已经回答在过去,可能有助于理解的关系,这样做的。
Similar problems of communicating between one form and another... whether attaching to "events" of one, or calling / setting values to/from each other. Here are a couple links to questions I've answered to in the past that may help understand the relationships to do so.
<一个href="http://stackoverflow.com/questions/7969582/how-to-update-textbox-in-form1-from-form2/7971828#7971828">Sample 1有明确的步骤创建两种形式的通信后退/来回对方
<一个href="http://stackoverflow.com/questions/4887820/how-do-you-pass-an-object-from-form1-to-form2-and-back-to-form1/4887906#4887906">Sample 2有些相似,但附加到形式之间的事件
这篇关于如何调用从父窗体用户窗体的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!