单个函数处理多个表单. [英] Multiple Forms handled by a single function.

查看:59
本文介绍了单个函数处理多个表单.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我一直在寻找答案,但没有成功.我什至不知道如何称呼这种编程设计.无论如何,这是我的问题:

我创建了多个窗体,但是窗体中的某些控件对象是相同的.除了相同的控件对象外,每个单独的表单还具有其他控件不常见的其他控件.我希望创建一个可以传递表单(可以动态创建)并能够管理所有表单之间通用的控制对象的函数.

这是我想做的一个非常粗糙的例子.可以说有两个类:

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 />

推荐答案

您的业务层应负责对文本的常规操作,您的UI层应相应地对其进行调用.您应该为两种形式之间共有的控件和功能组创建用户控件.
Your business layer should be responsible for common actions on text, and your UI layer should call it accordingly. You should create user controls for groups of controls and functionality that exist in common between two forms.


这篇关于单个函数处理多个表单.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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