Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted

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.

Posted
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.
  • Leaders
Posted

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

  • *Gurus*
Posted
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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

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...