问题描述
大家好,
我一直在寻找答案,但没有成功.我什至不知道如何称呼这种编程设计.无论如何,这是我的问题:
我创建了多个窗体,但是窗体中的某些控件对象是相同的.除了相同的控件对象外,每个单独的表单还具有其他控件不常见的其他控件.我希望创建一个可以传递表单(可以动态创建)并能够管理所有表单之间通用的控制对象的函数.
这是我想做的一个非常粗糙的例子.可以说有两个类:
Hi All,
I have been searching for an answer without any success. I dont even know how to call this programming design. Anyway, this is my question:
I have multiple Forms created, but some of the control object in the forms are the same. In addition to the same control objects, the each individual form has additional controls that are not common to the others. I wish to create a function that I can pass a form (which would be dynamically created) and be able to manage the control objects that are common between all forms.
This is a very crude example of what I wish to do. Lets say there are two classes with:
<br />
<pre><br />
public class FormA<br />
dim txtBoxA as System.Windows.Forms.Textbox<br />
dim txtBoxB as System.Windows.Forms.Textbox<br />
dim cbxBoxA as System.Windows.Forms.Checkbox<br />
end class<br />
<br />
public class FormA<br />
dim txtBoxA as System.Windows.Forms.Textbox<br />
dim txtBoxB as System.Windows.Forms.Textbox<br />
dim cboLine as System.Windows.Forms.Combobox<br />
end class<br />
</pre><br />
然后在主类中,我可以动态创建并调用
Then at the main class i could dynamically create and call
<br />
<pre><br />
Public class Main<br />
Sub Main<br />
select case OPTION<br />
case OPTION.formA<br />
generic = New FormA<br />
case OPTION.formB<br />
generic = New FormB<br />
end case<br />
<br />
MyControllingFunction(generic)<br />
<br />
End Sub<br />
</pre><br />
推荐答案
这篇关于单个函数处理多个表单.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!