Phylum Posted July 25, 2003 Posted July 25, 2003 There is a MdiChildActivate event that occurs on a parent MDI form. This event is raised when a child form is activated or closed. The help documentation is very limited on this event. I need to know 2 things. First, can you tell if the child is closing or being activated? Secondly, can you tell which index in the array of child forms is closing? Any help is appreciated Phylum Quote
Leaders dynamic_sysop Posted July 25, 2003 Leaders Posted July 25, 2003 you could create a handler for closing on your mdiParent form , eg : Private WithEvents frm As Form Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frmChild As New Form2() frmChild.MdiParent = Me.ActiveForm frmChild.Show() AddHandler frmChild.Closing, AddressOf frm_Closing '/// add any extra handlers that you would need here. End Sub Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles frm.Closing Dim f As Form = sender MessageBox.Show("closing " & f.Name) End Sub i'm sure it could be modified for an array of forms quite easily. Quote
Phylum Posted July 25, 2003 Author Posted July 25, 2003 The point is that there already is an event to cover this... Unfortunately they decided not to document it very well :( Perhaps I will have to research it more.. Thanks for your help dynamic_sysop. Quote
Leaders dynamic_sysop Posted July 25, 2003 Leaders Posted July 25, 2003 i mean have a universal event in your mdi parent that handles the closing of all child windows ( then you will see when a child window closes / get it's value ) not the standard event which is in the child window. eg , when an mdi child ( say called Child1 ) closes / attempts to close , this sub ( in your mdi Parent form ) will handle it / see which child form is closing ... Private Sub frm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles frm.Closing Dim f As Form = sender '//// the MDI CHILD. MessageBox.Show("closing " & f.Name) End Sub Quote
*Gurus* divil Posted July 25, 2003 *Gurus* Posted July 25, 2003 Nothing is passed to that event; You have to look at the ActiveMdiChild property to see which one has become active. This could be null - the event is raised when the last child has been closed. If you want to see which one was the last one activated, you'll have to keep track of that yourself. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
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.