一个表单到另一个表单检索数据库中的值 [英] one form to another form retrieve value in data base

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

问题描述

一个表单到另一个表单检索数据库中的值

one form to another form retrieve value in data base

推荐答案

如果您的意思是从一个表单中检索数据库中的数据而需要通过它到另一个,然后你如何做到这取决于表格之间的关系。



让我们调用表格从数据库获取数据来源,以及需要的表格数据目的地。



如果Source打开目的地显示数据,并等待它继续关闭。

要么:

1.1)在Destination中创建属性以接收该数据并在创建Destination实例之后但在调用ShowDialog之前设置它们。

1.2)更​​改目标构造函数接受这些值并在创建Destination实例时设置它们。



如果Source打开Destination以显示数据但不等待它关闭。

2)按1中的方式创建属性。 1以上。在Source中创建Destination的实例作为类级别变量,并更新属性。你可能想要处理Destination.FormClosed事件,让你知道你需要创建另一个事件。



如果目的地创建了源,那么

3)在Source中创建属性,并创建一个源触发的DataChanged事件和Destination句柄。然后,Destination可以通过属性访问数据并根据需要自行更新。
If you mean that you are retrieving data from a database in one form and you need to pass it to another, then how you do it depends on the relationship between the forms.

Let''s call Form getting data from database the Source, and the form that needs the data the Destination.

If the Source opens the Destination to display the data, and wait for it to be closed before continuing.
Either:
1.1) Create properties in the Destination to receive that data and set them after you create the Destination instance but before you call ShowDialog.
1.2) Change the Destination Constructor to accept the values and set them when you create the Destination instance.

If the Source opens the Destination to display the data but does not wait for it to close.
2) Create properties as in 1.1 above. Create you instance of Destination as a class level variable in the Source, and update the properties. You may want to handle the Destination.FormClosed event to let you know you will need to create another one.

If the Destination creates the Source, then
3) Create the properties in the Source and also create a DataChanged event which the source fires and the Destination handles. The Destination can then access the data via the properties and update itself as required.


这篇关于一个表单到另一个表单检索数据库中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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