By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

Ensure the form is disposed

P: n/a
How to ensure that a form is disposed?
When I work with modal forms I do the following:

using (Form1 frm = new Form1())
{
frm.ShowDialog();
}

As far as I read, when it ends the using scope, the form is disposed.
But if I don't use modal forms, like this:

Form1 frm = new Form1();
frm.Show();

In this case, when the user clicks on the X button, or a close button,
the form is disposed?

Junior.

Sep 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Junior,

Yes, when the user clicks on the close button, the form is disposed of.
When the message to close is received for the form, it calls Dispose.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"osmarjunior" <os*********@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
How to ensure that a form is disposed?
When I work with modal forms I do the following:

using (Form1 frm = new Form1())
{
frm.ShowDialog();
}

As far as I read, when it ends the using scope, the form is disposed.
But if I don't use modal forms, like this:

Form1 frm = new Form1();
frm.Show();

In this case, when the user clicks on the X button, or a close button,
the form is disposed?

Junior.

Sep 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.