如何在Windows应用程序中将Form1中的文本框上的值获取到Form2中的文本框中 [英] How to get values on textbox in form1 into textbox in form2 in windows apps

查看:117
本文介绍了如何在Windows应用程序中将Form1中的文本框上的值获取到Form2中的文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人帮助我了解如何在Windows应用程序中将form1的文本框的值转换为form2的文本框.

Somebody help me on How to get values on textbox in form1 into textbox in form2 in windows application.

推荐答案

Passing Data Between Forms[^] :thumbsup:


如果您也看过Ankur链接的文章,它的得分很低-原因是它包含一些内容最好避免的不良做法!

我在
此处发布了提示 [此处进行深入了解 [
If you look at the article Ankur linked too it has quite a low score - the reason is it contains some bad practices which are best avoided!

I posted a Tip here[^] which shows you how to do it correctly and an in depth article here[^].


采用两种形式form1.cs和form2. cs在每个表单上带有一个文本框,然后将每个表单上的文本框的修改器属性从private更改为public,将按钮添加到form1.cs通过双击form1上的按钮来生成其click事件,然后在按钮的点击事件
take 2 forms form1.cs and form2.cs with one textbox on each forms and then change the modifier property of the textbox on each form from private to public add a button to form1.cs generate its click event by double clicking the button on form1 and then add in the following code in the click event of the button
Form2 obj = new Form2();
obj.textbox1.Text = this.textbox1.Text;
obj.Show();
this.Hide();


然后运行该应用程序

一旦找到有用的答案,就对我的答案进行评分

谢谢&问候
基:rose:


and then run the application

Do rate my answer once you find it useful

Thanks & Regards
Radix :rose:


这篇关于如何在Windows应用程序中将Form1中的文本框上的值获取到Form2中的文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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