Form.Dispose vs. Form.Close

T

T Cordon

What is the difference between: Form.Dispose and Form.close. They both seem
to destroy the object. Or should both be called when closing a form? if so,
in what order?

Thanks
 
P

Paul

T Cordon said:
What is the difference between: Form.Dispose and Form.close. They both seem
to destroy the object. Or should both be called when closing a form? if so,
in what order?

Thanks

Hi!

The difference between Form.Dispose and Form.Close is large:

Dispose destroy the object, and
Close simply close the form (send message - WM_CLOSE), without destroy.
 
J

Justin Rogers

Dispose destroy the object, and
Close simply close the form (send message - WM_CLOSE), without destroy.

WM_CLOSE translates to WmClose() method on Form, which calls Dispose
under some circumstances. So the differences really aren't that large unless
you
are using validation and closing event cancellation logic.
 

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