Below is my code
private void btnCptKb5_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
textbox1.text = form1.textbox1.text;
}
Why is that I can't copy the value of form1 textbox?
Below is my code
private void btnCptKb5_Click(object sender, EventArgs e)
{
Form1 form1 = new Form1();
textbox1.text = form1.textbox1.text;
}
Why is that I can't copy the value of form1 textbox?
You didn't change Textbox2.Text
value
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 to pass values between forms in c# windows application?
2) Passing data between forms
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?
7) Passing Data Between Forms
8) Get data from one textbox on form1 from another textbox on form2