//in your child form set up a public event hander
public event EventHandler<EventArgs> ChildDoStuff;
protected virtual void OnChildDoStuff(EventArgs e)
{
if (ChildDoStuff != null)
ChildDoStuff(this, e);
}
// in you main form hook up this event handler to a function called DoStuff()
childform.OptimiserCancelled += new EventHandler<EventArgs>(DoStuffOnMainForm);
private void DoStuff(object sender, EventArgs e)
{
...
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
http://msdn.microsoft.com/en-us/library/87d83y5b(VS.80).aspx
Then you can iterate the MdiChildren() collection, or use the ActiveMdiChild() property, and cast the form(s) to your Interface type and call the methods that you have defined in the Interface.
It is possible to do this with Reflection as well but it is not as elegant. You would basically need to catch the exceptions generated with Try/Catch blocks and/or check for null returns indicating that the method/control you are looking for didn't exist.