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]
Loading
Komal PatelPosted Jan 7, 2009, 11:54 PM
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
Alex KobyPosted Jan 7, 2009, 4:13 PM
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());
}
}
Ryan AlfordPosted Jan 7, 2009, 3:13 PM