I have two forms, and I need pass a value from form1.textbox1 to form2.variable
Form1:
string Ed = \"\", En = \"\";
public string En1
{
get { r
This question may be old, but anyways...
Another way to do it is, to have a constructor in form2 that accepts an argument of the same type of the data you want to pass to, and, when button in form1 is clicked, you create the instance of form2 using the constructor that accepts the argument, and pass the data to it.
//Form1
Form2 form2;
button1_clic(object sender, eventArgs e)
{
form2 = new Form2(textbox1.text);
form2.Showdialog();
}
//Form2
string var = string.empty;
public Form2(string val)
{
InitializeComponents();
var = val;
}