I have to call a form2's click event on form1. There is many example with "call function from another form" But there is not had when form is already opened. How do I click form2's button on form1?
//form1 code
private void button1_Click(object sender, EventArgs e)
{
var _callForm = new form2(); //this open's new form but it was already open.
_callForm.StartPosition = FormStartPosition.CenterScreen;
_callForm.textbox1 = _sampletext;
_callForm.checkbox1.Checked = true;
_callForm.form2button1.PerformClick();
_callForm.ShowDialog();
}
//form1 and form2 are still opened.
//form2 code.
//checkbox1,form2button1,textbox1 These are public in designer code
private void form2button1_Click(object sender, EventArgs e)
{
//do something
}