Click here to Skip to main content
12,354,763 members (61,769 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET3.0 C# .NET
I have a MDIParent form with two menubar
when we click on annotation manu it will open annotation form
and when we click on retention menu it will open retention form..
the problem is when i click on annotation or retention menu for first time, it opens form, after closing form when i click again to open form it throws an exception "Cannot access a disposed object. Object Name 'PictureBox'"..

my both annotation and retention form has some dynamically created picturebox. Is there any problem with dat pictureboxes?

m using following code on MDI form to open my forms..
private void annotationToolStripMenuItem_Click(object sender, EventArgs e)
Annotation frmAnnotation = new Annotation();
private void retentionToolStripMenuItem_Click(object sender, EventArgs e)
            Retention frmRetention = new Retention();
Posted 16-Feb-11 22:38pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Don't see anything wrong with that code. You need to create a new form each time as it gets disposed when closed but you're doing that.

Looks like the scope of the picture box is wrong. You haven't made it a static or anything?
Vinaykumar Singh 17-Feb-11 4:48am
i created picturebox like dis..
static public PictureBox _imgedt = new PictureBox();
Rob Philpott 17-Feb-11 4:55am
That's the problem then. Remove that static keyword and instantiate the picturebox in your form constructor.
Manfred R. Bihy 17-Feb-11 4:58am
Good answer! 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 17 Feb 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100