Search code examples
c#winformsmdichild

How to close MDI Child form C#


How do you close a MDI Child form within that child MDI form using a RETURN button which will bring me back to the Parent Form? So far i have used the code:

if (ActiveMdiChild != null)                 
            ActiveMdiChild.Close(); 

But this doesn't work. I have tried numerous methods but nothing has worked so far Any help is much appreciated!!


Solution

  • why not use:

    foreach (Form c in this.MdiChildren)
    {
       c.Close();
    }