Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

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.

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...