I am developing a windows based application in .net.
I have two forms. Form2 is instantiated and displayed when an event occurs in form1.
public partial class Form1 : Form
{
...
private void button1_Click(object sender, EventArgs e)
{
....
}
public void button2_Click(object sender, EventArgs e)
{
Form2.parent = this;
Form2 f2 = new Form2();
f2.show();
}
}
public partial class Form2 : Form
{
...
public static Form parent;
private void button3_Click(object sender, EventArgs e)
{
.... //want to call Form1's button1_Click() function.
}
}
Now in Form2's button3_Click() function I want to call Form1's button1_Click() method.
I tried
parent.button1_Click(button3,null);
but this is not working.
please help!