I have two forms. One is MDI parent and the other is the MDI child. When a button on the parent is clicked the form of the child opens. I have written a code to prevent the form from duplicating. Those methods are as;
public Form IsFormAlreadyOpen(Type FormType)
{
foreach (Form OpenForm in Application.OpenForms)
{
if (OpenForm.GetType() == FormType)
return OpenForm;
}
return null;
}
public static Form1 f1;
public void open_Form1()
{
Form UForm = null;
UForm = IsFormAlreadyOpen(typeof(Form1));
if (UForm == null)
{
UForm = new Form1();
UForm.MdiParent = this;
UForm.Show();
}
}
This piece of code is available in the MDI Parent form. and them the button is clicked the method "open_Form1()" is called and it open the child form.
But the problem is how can I access the public method which is written in the child form? On the child form i have this code.
public void somefunction()
{
/*code*/
}
How can i call this method from the MDI Parent?