mjb3030 Posted February 12, 2004 Posted February 12, 2004 I have an MDI application. I am opening the MDI children from within the parent like this: With frmCal .MdiParent = Me .Show() .Location = new Point(0,0) End With The problem I am having is that when I try to close the parent (say I click the close (X) button), it closes one of the child forms. If I click it again, it closes another child form. It keeps doing this until all the child forms are closed. Then, it will finally close on the final click. What do I have to do to make sure it closes everything with one click? Quote
Administrators PlausiblyDamp Posted February 12, 2004 Administrators Posted February 12, 2004 What code do you have in the MDI parents closing event? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mjb3030 Posted February 12, 2004 Author Posted February 12, 2004 I tried adding: frmCal.Close() frmMain.Close() frmTest.Close() After that didn't work, I discovered that it isn't even hitting the Closing event of the parent form until the final click when it closes itself. Quote
mjb3030 Posted February 13, 2004 Author Posted February 13, 2004 OK... I found this on MSDN: --------------------------------- Note Keep in mind that when closing an MDI parent form, each of the MDI child forms raises a Closing event before the Closing event for the MDI parent is raised. Cancelling an MDI child's Closing event will not prevent the MDI parent's Closing event from being raised; however, the CancelEventArgs argument for the MDI parent's Closing event will now be set to true. You can force the MDI parent and all MDI child forms to close by setting the CancelEventArgs argument to false. --------------------------------------- So, now I understand why the parent form's Closing event isn't being called right away, but that still doesn't explain why my application closes one child window and then stops. Why won't it go through and close them all? I have one hidden form that is constantly collecting data from a USB data acquistion device. Could that have something to do with it? I don't see why it wouldn't just close that also. Quote
mjb3030 Posted February 13, 2004 Author Posted February 13, 2004 Never mind... I'm a big dumb animal. I had set e.cancel to true in 2 of my child forms' Closing events. as soon as I removed that, it worked. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.