如何从一种形式获取数据到另一种形式. [英] How to get data from one form to another.

查看:103
本文介绍了如何从一种形式获取数据到另一种形式.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Win应用程序,该应用程序有两种形式,第一种形式是输入形式,第二种形式是加载形式.........现在这是我需要第一种形式的输入形式的问题在第二种形式.....但是我无法到达form1的数据,如何将数据从form1传递到form2 .....




请帮忙......


问候,
Ahsan Naveed

i have a win app that has two forms the form gets input in first form and then the second form loads............now heres the problem the input i take in first form is required in second form........but i cannot reach the data of form1 how do i get the data from form1 to form2........




please help......


Regards,
Ahsan Naveed

推荐答案

这是有关表单协作的流行问题.最健壮的解决方案是在Form类中实现适当的接口,并传递接口引用而不是对Form的整个实例"的引用.请查看我过去的解决方案以获取更多详细信息:如何以两种形式在列表框之间复制所有项目 [ http://en.wikipedia.org/wiki/Accidental_complexity [ http://en.wikipedia.org/wiki/Loose_coupling [
This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

Please also see other solutions in this discussion. If the application is simple enough, the solution could be as simple as declaring of some internal property in one form and passing a reference to the instance of one form to the instance of another form. For more complex projects, such violation of strictly encapsulated style and loose coupling could add up the the accidental complexity of the code and invite mistakes, so the well-encapsulated solution would be preferable.

Please see also:
http://en.wikipedia.org/wiki/Accidental_complexity[^],
http://en.wikipedia.org/wiki/Loose_coupling[^].

—SA


这里是一篇文章- ^ ]进行查询.
Here is one article - Passing Data Between Forms[^] for your query.




看看这些提示:
在两种形式之间传输信息,第1部分:父级到子级 [^ ]
在两种形式之间传递信息,第2部分:子女到父母 [ ^ ]
在两种形式之间传输信息,第3部分:子对子 [ ^ ]
Hi,

Have a look at these Tips:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]


这篇关于如何从一种形式获取数据到另一种形式.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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