如何在没有数据库连接的情况下将在一个表单上输入的信息显示到另 [英] How to display information entered on one form to another form without database connectivity?
本文介绍了如何在没有数据库连接的情况下将在一个表单上输入的信息显示到另的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
i是C#的乞丐...我需要帮助来开发我的第一个应用程序..
hello
i am a begginer to C#...i need help to develop my first application..
推荐答案
在第二个表单上创建一个属性e从第一个表单设置此属性,然后显示第二个表单。
表单2:
Create a property on the second form e set this property from the first form, then you show the second form.
Form2:
public string Information
{get; set;}
Form1:
Form1:
Form2 f = new Form2();
f.Information = "bla bla bla"
f.Show();
这是形式协作的流行问题。最强大的方法是在表单类中实现适当的接口。请看我过去对这个问题的回答:如何以两种形式复制列表框之间的所有项目 [ ^ ];看其他建议和讨论。
-SA
This is a popular question of form collaboration. The most robust way is to implement appropriate interface in form class. Please see my past answer to this question: How to copy all the items between listboxes in two forms[^]; see other suggestions and the discussion.
—SA
最好的方法是创建一个全局类并从数据库中检索信息并将其存储在该类中,当任何表单需要该数据时,它从全局类中读取它
the best way is to create a global class and retrieve information from the database and store it in that class, and when any form needs that data it reads it from the global class
这篇关于如何在没有数据库连接的情况下将在一个表单上输入的信息显示到另的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文