Results 1 to 11 of 11

Thread: [Resolved] How to detect when a child form as been closed?

Threaded View

  1. #5

    Thread Starter
    Lively Member Blupig's Avatar
    Join Date
    Apr 2008
    Posts
    118

    Re: How to detect when a child form as been closed?

    I've tried what you've just suggested but I still get the same "skipping" effect. Here's my AddHandler code:

    Code:
        Private Sub RunescapeToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunescapeToolStripMenuItem1.Click
            Dim F As New frmRunescape
            F.MdiParent = Me
            AddHandler F.FormClosed, AddressOf ChildFormClosed
            F.Show()
            RefreshWindows()
        End Sub
    
        Private Sub ChildFormClosed(ByVal sender As Object, ByVal e As EventArgs)
            Dim c As frmRunescape
            c = DirectCast(sender, frmRunescape)
            RefreshWindows()
    
        End Sub
    Is there some way to dynamically remove a form from an MdiChildren collection directly?

    EDIT: I think I know what the problem is. I added a pause to the AddHandler as well as the Form_Closed event for debugging . It seems that both events are not raised while the form is completely closed, but instead it's raised right before the form closes. So, by adding code into Form_Closed, it doesn't do anything since the form is still open and technically part of the MdiChildren collection.
    Last edited by Blupig; Aug 14th, 2010 at 10:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width