Closing MDI Child form problem??

A

al

Greegins,

I have child form included in an MDI form. Things work fine until I
Close the child form. The prolem is when I try to open that same
child form form menu, app crashes saying it can't create dispoed form.
I declare and instansiate the child form in the declartion section of
MDI parent and have .show method of the child form to display it. How
can I avoid the carsh problem??


Dim frmempInstance As New Emp 'this is the instansiation of the
child form

Private Sub Emp_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Emp.Click

frmempInstance.Show() 'here the app carshes after second opening the
child form.

End Sub

MTIA,
Grawsha
 
A

Armin Zingler

al said:
Greegins,

I have child form included in an MDI form. Things work fine until
I Close the child form. The prolem is when I try to open that
same child form form menu, app crashes saying it can't create dispoed
form.
I declare and instansiate the child form in the declartion section
of
MDI parent and have .show method of the child form to display it.
How can I avoid the carsh problem??


Dim frmempInstance As New Emp 'this is the instansiation of the
child form

Private Sub Emp_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Emp.Click

frmempInstance.Show() 'here the app carshes after second opening
the child form.

End Sub

If you are the same "al" as in the other thread, you have already gotten the
answer that you can handle the Closed event of the child form. In the event
handler for the closed event, set frmempInstance to Nothing. The next time
you want to show the child form, check if the variable is nothing. If it is,
create a new instance and show it. If it is not, you can activate the
already visible child form by calling it's Activate method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top