Reopen form - NullReferenceException

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
 
C

Chris Tacke, eMVP

I think closing it disposes it. Try either hiding the Form or creating a
new instance when you want to re-show it.
 
P

Peter Bladh

I've tried to create a new instance but I still get the
NullReferenceException.
Any other suggestions?

/peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top