Form.Dispose vs. Form.Close

  • Thread starter Thread starter T Cordon
  • Start date Start date
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
 
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.
 
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.
 
Back
Top