Windows Forms close/hide

waraq

Member
Joined
Dec 18, 2006
Messages
23
Location
Harrison, TN
Programming Experience
Beginner
I have two Windows forms open on the screen and I close one of the two Windows by clicking on the uper red X conner "Close Button" of the Windows form.
The second form on the screen have a button that will open the form again, but I have a message that said:

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

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

Every time I choose to close the form at the top right side of the form.

I need to know what I'm doing wrong. The form have been close and the button on the next form is able to open the form again by using this code:

Chequera.Show()

Also, if have chose to close the form by clicking on the object button with a code: Chequera.Hide, it will not give me any problem.

I can close and open an infinit times, execp for the "Close Button" at the top of the form that is cousing me problem.

I will appreciate your help.

Thank you


Willy
 
Check if the object instance has been disposed, if so create a new one.
VB.NET:
If Chequera.IsDisposed Then Chequera = New frmRChs
 
Forms

I really appreciate your help Jhon. I will try that line of code. You must know this computer languege well, I remember the las time you help me with some other problem. I hope you making big money doing so.

Also, I did try this line of code:

Portada.ShowDialog()
Me.Show()
But I think your code is more efficient.

Thank you so much.

Willy
 
Back
Top