从另一种形式传递价值 [英] Passing Values From The Another Form

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

问题描述

嗨;对所有优秀的人
我想将值form1传递给form2,而表单正在运行

例如,我在form1和form2上有一个文本框
我想在form1的文本框中输入一些内容,然后单击按钮vs.
输入的内容将通过form2

Hi; Good work to all who
I wantto pass values form1 to form2, while forms running

For example I have a textboxs on form1 and form2
I wantto enter some things in textbox which in form1 then click button vs.
the entered things will pass textbox which in form2

推荐答案

传递的文本框,有几种方法可以做到这一点,包括Form2中的公共属性会更新文本框.
但是,执行此操作的正确方法是在Form1中通知事件数据可用",该事件在Form2中进行处理并根据需要进行更新.
There are several ways to do this, including public properties in Form2 which updates the textbox.
However, the proper way to do it is to signal an event "Data available" in Form1 which is handled in Form2 and updates as necessary.


Google是您的朋友.试试这些:

将数据从一种表单传递到另一种表单 [如何从-发送值一个窗体到另一个窗体在c-winforms应用程序中 [
Google is your friend. Try These:

Pass Data from One Form to Another Form[^]

How to send-values-from-one-form-to-another-form-in-c-winforms-application[^]

hope it helps :)


这是有关表单协作的常见问题.最健壮的方法是在表单类中实现适当的接口.

有关更多详细信息,请参见我过去的回答:
如何在列表框之间复制所有项目两种形式 [ ^ ].

另请参见整个讨论以了解不同的选择.

—SA
This is a popular question about form collaboration. Most robust way is implementing appropriate interface in the form class.

For more details, see my past answer:
How to copy all the items between listboxes in two forms[^].

See also the whole discussion for different options.

—SA


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

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