Hi
The user enters his name on the textbox on Form1 as soon as he press the button enter, Form1 closes and Form2 open. I want to get the string that was entered in textbox in Form1 to be displayed in Form2.
Hi
The user enters his name on the textbox on Form1 as soon as he press the button enter, Form1 closes and Form2 open. I want to get the string that was entered in textbox in Form1 to be displayed in Form2.
How to parse a variable in C# window form?
KeeperOC
Earl Jr
public class Form2 : Form
{
public string Username
{
get
{
return txtUsername.Text;
}
set
{
txtUsername.Text = value;
}
}
}
Now in form1 you can do something like this:
private void button1_Click( object sender, EventArgs e )
{
Form2 form = new Form2();
form.Username = txtName.Text;
form.Show();
}
You can take a look at this thread to.
Nitesh Menon
The key fact you should remind on this issue is that by having a reference set from the 1st to the 2nd Form you are able to call all functinalities of the second Form within the 1st.
So when you have set an reference, the 1st objects does know the 2nd.
Note that in your case the 2nd Form does NOT know the 1st since there is no reference backwards.
mike93108