Hi,
I created a pop-up window that is opened through menu. When I click the menuitem, I use this code to make the form visible:
[code]
popupform.Show();
[/code]
After I close the popup form and then try to open it again it says
[quote]
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Form'
[/quote]
ObjectDisposedException
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Komal Patel20 reputationPosted Jan 7, 2009, 6:54 PM EST
this might becuase you are creating your form object at class level and never going to reinitialize it after closing it
when ever we close form it disposes its object so if possible then reinstantiate your form object when ever your open new window
Ryan AlfordRank #1,411 · 1.2K reputationPosted Jan 7, 2009, 10:13 AM EST
Alex Koby6 reputationPosted Jan 7, 2009, 11:13 AM EST
public class program:System.Windows.Forms.Form{
Form popup;
public program(){
loadPopUp();
MainMenu menu=new MainMenu();
MenuItem menu1=new MenuItem("Popup"),item=new MenuItem("Show PopUp");
menu.MenuItems.Add(menu1);
menu1.MenuItems.Add(item);
item.Click+=delegate{
popup.Show();
}
this.Menu=menu;
}
void loadPopUp(){
popup=new Form();
popup.Size=new Size(200,200);
}
[STAThread]static void Main(){
Application.Run(new program());
}
}