Question cannot access a disposed object.Object name. ' PanelEx'

bintoy

New member
Joined
Jan 17, 2013
Messages
2
Programming Experience
Beginner
hello.......
i have form1,form2,form3 and form4 the form1 is the main form and form2 has a treeview control to display the panel from form3 and form4.i use tablelayout panel in the form2. the problem is that when i close the form2 i got this error: cannot access a disposed object.Object name. ' PanelEx'
is there anyone can help? any comment is highly appreciated.
 
When you close a form it is disposed and when you dispose a form all the design-time controls and components it contains are disposed too. That's why the exception occurs. Maybe you could provide an explanation of what you're actually trying to achieve and show us what you're actually doing and we could then help you fix it. As it stands, all we can do is guess, which is likely to be a waste of everyone's time.
 
thank you ..,,Sir is it possible to solve this kind of error... error.png
 
The solution depends on the intention. Presumably 'frmconreport' refers to a form that has been disposed, therefore PanelEx1 on that form has also been disposed. That means that it cannot be added to another container. If you don't provide a clear explanation of what you're trying to achieve and how you're trying to achieve it then we can't really provide a solution.

What I will say is that moving a control from one form to another is something that you should pretty much never be doing. Moving data between forms is one thing but controls is quite another. Most likely you should be retrieving some data from that form and populating a new control in the current form.

If you're determined to keep going the way you are then all I can say is that you would have to move the control between forms before its original form is disposed.
 
Back
Top