Parent/Child error on open

amber

Member
Joined
Oct 27, 2004
Messages
20
Programming Experience
Beginner
Hello,

I have a parent form, with a menu item used to enter the child form.
If I open the child form, then close it, and try to reopen it from the parent, I get the error message:

"An unhandled exception of type 'System.ObjectDisposedException' occurred in system.windows.forms.dll

Additional information: Cannot access a disposed object named "frm1"."

What is causing this?

Thanks,
Amber
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
you should have a global variable being the form

such as friend mychildform as childform

then when you open the child form have it make a new instance of the form

such as:
mychildform = new childform
mychildform.parent = me '(me being the parent form fyi)
mychildform.show
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Yes but if you just did mychildform.show, closed it and then tried to use mychildform.show again youd get that error.
 
Top Bottom