I have a Windows Forms application which has two forms: Form1 and Form2. The startup form is Form1, Form2 is loaded by a Button click.
After I load Form1, but before I load Form2, this is what I get:
MsgBox(Form2 Is Nothing) 'returns true
MsgBox(Form2.IsDisposed) 'returns false
MsgBox(Form2 Is Nothing) 'returns false
Form2.Dispose()
MsgBox(Form2 Is Nothing) 'returns false
MsgBox(Form2.IsDisposed) 'returns false
Form2.Close()
MsgBox(Form2 Is Nothing) 'returns false
MsgBox(Form2.IsDisposed) 'returns false
If I load Form2 and then close it with a Close box:
MsgBox(Form2 Is Nothing) 'returns false
MsgBox(Form2.IsDisposed) 'returns false
Why is Form2 never disposed of, and how one can completely dispose of it?