I would like to know, in my form1 i have a textbox and button. Wheres in form2 i have a button. this is a sample. In my form1 i have a method called as enabledTextBox. When i click in my form1 button it will direct me to form2 via showDialig whereas when i click the button in form2 it should set the textbox property via calling the method enabledTextBox and exit the form 2. The problem is when i click the form2 exist without setting the value of textbox in form1 as set in form1 button click event. I would like to execute when the button clicks. below are my codes
Form1.cs
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2();
f2.ShowDialog();
}
public void enableTextBox(Boolean isEnabled)
{
textBox1.Enabled = isEnabled;
}
}
Form2.cs
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f1 = new Form1();
f1.enableTextBox(true);
this.Close();
}
}
can i know hwre is my error is and the mistake i am doing