从另一个窗体 Winforms 传递值

编程入门 行业动态 更新时间:2024-10-27 14:30:36
本文介绍了从另一个窗体 Winforms 传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

web中传递表单的所有教程都是从form1然后打开form2然后传值.

All the tutorial in passing forms in the web are all from form1 then open form2 and then pass the value.

我想要一些相反的东西.form1 和 form 2 是打开的,所以如果你在 form2 中点击确定,你在 form 2 中得到的值将在 form 1 中传递.

I want something reverse. form1 and form 2 is open so if you click ok in form2 the value you get in form 2 will be passed in form 1.

例如.form1 单击按钮 openform2button(表单 2 显示)在文本框(在表单 2 中)上写 7(数字 7)单击按钮 okbutton 然后表单 2 在表单 2 关闭后关闭表单 1 中的文本框会将数据存储在表单 2 中.因此,您将放入文本框 form2 中的 7 将保存并传输到文本框 form1 中.这可能吗?

ex. form1 click buttton openform2button (form 2 shows) write 7 (number 7) on a textBox (in form2) click button okbutton then form 2 closes after form2 closes the textbox in form1 will store the data in form2. so the 7 you will put in textbox form2 will be saved and transferred in textbox form1. is that possible?

推荐答案

有多种方法可以做到:

在 form1 和 form2 之间共享一个模型对象.让 form2 公开一个 form1 订阅的事件.传递事件参数中的值.让 form2 将该值公开为 form1 在 form2 关闭后读取的公共属性.

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

更多推荐

[db:关键词]

本文发布于:2023-04-25 11:41:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115343.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗体   Winforms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!