Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form available "globally" 1

Status
Not open for further replies.

SH4F33

Programmer
Apr 1, 2005
58
MU
Hello there. I'm a bit new to .Net and its very different from vb6. Well, Ive set an mdi container, and created another form which is supposed to be the child. But since u cant call a form like that, u have to create an instance of it everytime.

I wanted to create an instance of a form, and use this form throughout the application.

Ive added a class (clsForms)put the following code:
Code:
Public shared myFrom as new Form1

So each time I need that form, I just call
Code:
clsForms.myForm.Show

Now making this form a child, I've added a menu in my Mdi and call the child like that:
Code:
clsForms.myForm.mdiparent=me
clsforms.myform.show

It works great. But after closing the child(myForm) and clicking on the menu again, the child was supposed to show again, but instead, i get the following error:

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

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

Is there a way to make a form available globally (creating an instance of it and use it everytime) instead of creating a new instance everytime?

Thanks.
 
in the closing event of form1 put this

Code:
e.cancel = true
me.hide


Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top