Can an MDI child close and MDI parent?



I've got a situation in a VB 2003 Windows application with an MDI form and a
child form. In certain situations, when the child is closed by the user, I
also want to close the MDI parent. Is there a way to close the MDI parent
with code in the child form?

In the MDI child form, I have tried:


but that doesn't appear to work. Is that because of object references in
the parent that are still alive? Is this even possible?




Family Tree Mike

Gillard, Form1.Close looks like a static method call on class Form1. Is
that what you meant?

DaveP, It is possible to close the app from the child forms. I would raise
an event for the main app to handle the close operation.



James Hahn

The idea of tryng to close the parent from the child never seemed qute
proper to me. The technique I have used is for the child to change a
property of the parent as it is closing, and then to put the code to clean
up the other children and close down the parent in the change event for that
parent property. At first it seemed like a kludge, but in practice it is
very effective. Of course, you should choose a property of the parent that
the user isn't going to change. For instance, change the text of the parent
to "Closing", and put the shutdown code in the parent's textchanged event.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question