When closing the last child window in the application, I need to disable menu items like Save and Print. I have all the logic written to do so, but when the last child window is closed from its own 'X' button instead of the parent window's Close menu item, the parent still thinks there's one form open for some reason.
After closing the last child window using its 'X' button, the menu items are still enabled. But if I click the Close or Close All menu buttons on the parent, then the menu items are disabled correctly.
I have a sub in the parent called UpdateControlState that uses MdiChildren.Length to handle menu items. I tried to use the code below but it never gets called:
Public Sub ClosedHandler(ByVal Sender As [Object], ByVal e As EventArgs) Handles MyBase.Closed
mainWin = Me.MdiParent
'If there are no child windows, then disable menu and toolbar items.
If mainWin.MdiChildren.Length = 0 Then
How can I force an update of the parent window's mdiChildren collection? Should I?