27/02/2014 by Nitesh

How to Add Child Forms to a Menu Item automatically in MDI Windows Form Application


When working with MDI applications in Windows forms, on several occasions we end up opening a lot of child forms and then finding across where the child form is. To provide a nice user experience, it is advisable to display all open child forms under a menu named “Windows”. This is not a must requirement but a nice to have feature. If you did not get what I am trying to say, you might get it from the screenshot below.


In the screenshot I have a MDI form open with 3 child forms inside it. As soon as you open a new child form or close an existing child form, this menu item automatically adjusts itself. In this post we will see how this can be achieved.

The best thing about this implementation is that for implementing this so handy feature, you do not have to write a single line of code. Below are the steps that needs to be done.

  • Add a MenuStrip control to the MDI form. Lets name it as “menuStrip”
  • Select the “menuStrip” and add a MenuItem to this “menustrip”. Lets name it as “windowsMenu”
  • Select the “menuStrip” control again and press F4 to access the Properties window.
  • Select the MdiWindowListItem property and assign the windowsMenu to this property.
    mdi -2
  • You’re done. Now, whenever you open a child form in the MDI parent form, a menu item will be automatically added to the menu item “windowsMenu” and when you close the form, the menu is auto adjusted.

Hope you like this post. Keep learning and sharing!