该textbox1.Text不能从另一种形式复制textbox2.Text值形式、Text

2023-09-02 02:03:44 作者:你的眼里有星星

下面是我的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)How到形式的C#Windows应用程序之间传递值?

2)传递形式之间的数据

3)switching形式而不会丢失信息

4)windows.form C#形式之间移动

5)Communicate窗口的形式在C#中两者

6)形式之间数据共享

7)传递数据形式之间

8)Get在窗口2