Reopen form - NullReferenceException

  • Thread starter Thread starter Peter Bladh
  • Start date Start date
P

Peter Bladh

Hi

I have some problem with reopening forms

Scenario

I have a form: frm1

I set frm1.Text in the GotFocus event

I close the form with frm1.Close()

I open frm1 again

I try to set frm1.Text but I get a NullReferenceException.


Why does that happen?
If I show a MessageBox after that and close it the GotFocus event gets
raised again and then I don't get the exception.


Really need some help!!
/Peter Bladh
 
I think closing it disposes it. Try either hiding the Form or creating a
new instance when you want to re-show it.
 
I've tried to create a new instance but I still get the
NullReferenceException.
Any other suggestions?

/peter
 
Back
Top