如何将数据传输到另一种形式 [英] how to transfer data to another form

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

问题描述

我正在做一个数据库,我的前端是c#,后端是sql。我有2种形式,即mainform和member。 mainform是mdiparent,成员是mdichild。

成员包含一个计时器,用于计算sql数据库中的记录数。

i想要显示计数的文本在mainform上的工具条标签上。

解决方案

表单协作的问题几乎是空的,因为正确的方法应该从理解表单类及其实例开始仍然是类和实例,因此使用它们不会在表单和其他类和对象之间产生原则上的差异。尽管如此,这个问题很受欢迎,所以我写了一篇特别针对此类案例的文章:一次回答的许多问题 - Windows窗体或WPF Windows之间的协作 [ ^ ]。



我不知道您为什么决定使用计时器,你会如何使用它;但所有事情都以类似的方式完成。我只会注意到它似乎没有多大意义。如果你想讨论它,你可以对它进行评论或提出另一个问题。



最后,关于MDI,这里有一个想法:谁需要MDI?为什么要折磨自己并吓跑你的用户?

帮自己一个大忙:根本不要使用MDI。没有它,您可以更轻松地实现设计,质量更好。 MDI甚至被微软高度劝阻,事实上,微软将其从WPF中删除并且很难支持它。更重要的是,如果您使用MDI,您将吓跑所有用户。只是不要。请参阅:

http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages

如何在WPF中创建MDI父窗口?



我可以解释做什么。请看我过去的答案:

如何在WPF中创建MDI父窗口?

关于在WPF中使用MDI窗口的问题

MDIContainer给出错误

如何设置最大化的子表单,最小化最后一个子表单



-SA

i am doing a database with my frontend as c# and backend as sql. i have 2 forms namely mainform and member. mainform is mdiparent and member is mdichild.
member contains a timer which is used to count the number of records from sql database.
i have want to display the text of the count on a toolstrip label on the mainform.

解决方案

The question of the form collaboration is pretty much empty, because right approach should start from understanding that forms classes and their instances are still classes and instances, so working with them makes no principle differences between forms and another other classes and objects. Nevertheless, the question turned out to be quite popular, so I wrote an article special for such cases: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows[^].

I have no idea why did you decide to use a timer and how would you use it; but all things are done in a similar ways. I'll only note that it does not seem to make much sense. If you want to discuss it, you can comment on it or ask another question.

Finally, as to MDI, here is the idea: who needs MDI, ever? Why torturing yourself and scaring off your users?
Do yourself a great favor: do not use MDI at all. You can do much easier to implement design without it, with much better quality. MDI is highly discouraged even by Microsoft, in fact, Microsoft dropped it out of WPF and will hardly support it. More importantly, you will scare off all your users if you use MDI. Just don't. Please see:
http://en.wikipedia.org/wiki/Multiple_document_interface#Disadvantages,
How to Create MDI Parent Window in WPF?.

I can explain what to do instead. Please see my past answers:
How to Create MDI Parent Window in WPF?,
Question on using MDI windows in WPF,
MDIContainer giving error,
How to set child forms maximized, last childform minimized.

—SA


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

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