C# :how to access textbox values of form1 from form2
-
hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)
senthil
-
hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)
senthil
There are many ways to acheive this, the easiest is to adjust the constructor for form2 to accept a textbox argument and store that as a variable in the form2 class in the constructor. Then you can access or change any of the form1.textbox properties from form2.
-
hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)
senthil
I suggest you read this article: http://www.codeproject.com/KB/dotnet/passingvaluesbetweenforms.aspx[^][^]
#region signature my articles #endregion