以下是我的代码
private void btnCptKb5_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
textbox1.text = form1.textbox1.text;
}
为什么我无法复制form1文本框的值?
答案 0 :(得分:5)
您没有更改Textbox2.Text
值
您正在创建一个全新的表单实例,并尝试访问该表单的文本框值。即使您的代码有效,它也将始终为空。
我认为这个问题是StackOverflow中最常见的问题你可以看看这些问题,我相信你会找到一个合适的答案:
1)How to pass values between forms in c# windows application?
3)switching between forms without loss of information
4)windows.form c# moving between forms
5)Communicate between two windows forms in C#
6)How to share data between forms?
8)Get data from one textbox on form1 from another textbox on form2