textbox1.Text 无法从另一个表单复制 textbox2.Text 值 [英] The textbox1.Text can't copy the textbox2.Text value from another form
本文介绍了textbox1.Text 无法从另一个表单复制 textbox2.Text 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的代码
private void btnCptKb5_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
textbox1.text = form1.textbox1.text;
}
为什么我不能复制form1文本框的值?
Why is that I can't copy the value of form1 textbox?
推荐答案
您没有更改
Textbox2.Text
值您正在创建一个全新的表单实例,并尝试访问该表单的文本框值.即使您的代码有效,它也将始终为空.
You are creating a completely new form instance,and trying to access that form's textbox value.It will be always empty even if your code works.
我认为这个问题是 StackOverflow 中最常见的问题你可以看看这些问题,相信你会找到合适的答案:
I think This question is most commonly asked question in StackOverflow You can take a look at these questions, and I'm sure you will find an appropriate answer:
1) 如何在之间传递值c# windows 应用程序中的表单?
2) 在表单之间传递数据
6) 如何在表单之间共享数据?
7) 在表单之间传递数据
8) 从form2上的另一个文本框从form1上的一个文本框获取数据
这篇关于textbox1.Text 无法从另一个表单复制 textbox2.Text 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文