该textbox1.Text不能从另一种形式复制textbox2.Text值 [英] The textbox1.Text can't copy the textbox2.Text value from another form
问题描述
下面是我的code
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
值
您正在创建一个全新的表单实例,并试图访问该窗体的文本框value.It将永远即使你的code ++工程,空的。
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.
我觉得这个问题是最常见的问题在计算器你可以看看这些问题,我相信你会找到一个合适的答案:
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)<一href="http://stackoverflow.com/questions/1205195/how-to-pass-values-between-forms-in-c-sharp-windows-application">How到形式的C#Windows应用程序之间传递值?
3)<一href="http://stackoverflow.com/questions/6333644/switching-between-forms-without-loss-of-information">switching形式而不会丢失信息
4)<一href="http://stackoverflow.com/questions/1250350/windows-form-c-sharp-moving-between-forms">windows.form C#形式之间移动
5)<一href="http://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c-sharp">Communicate窗口的形式在C#中两者
6)形式之间数据共享
7)传递数据形式之间
8)<一href="http://stackoverflow.com/questions/20869899/get-data-from-one-textbox-on-form1-from-another-textbox-on-form2/20869998#20869998">Get在窗口2
这篇关于该textbox1.Text不能从另一种形式复制textbox2.Text值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!