Results 1 to 4 of 4

Thread: Close() and Closing()

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Close() and Closing()

    What is the difference between the Form_Close() and Form_Closing() events? If I want to empty variables (ie: Var = 0) which event would be better?
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  2. #2
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: Close() and Closing()

    Form_Closing() is where you should put the code to validate if yes or no the form will be close. by setting the e parameter
    VB Code:
    1. e.Cancel=True
    it append just before de form is close.

    In the Form_Close()

    The form is close so this is the place you should reset value or else ...

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Re: Close() and Closing()

    Form_Close is an instruction, a method indicating the form should be closed now.

    Form_Closing is a happening, an event which is executed AS the form is closing.

    Theoretically I guess both should be valid in disposing objects, but out of habit I usually use the Close() method.

    MSDN seems to have a similar description for both:

    When a form is closed, all resources created within the object are closed and the form is disposed. You can prevent the closing of a form at run time by handling the Closing event and setting the Cancel property of the CancelEventArgs passed as a parameter to your event-handling method. If the form you are closing is the startup form of your application, your application ends.

    The Closing event occurs as the form is being closed. When a form is closed, all resources created within the object are released and the form is disposed. If you cancel this event, the form remains opened. To cancel the closure of a form, set the Cancel property of the CancelEventArgs passed to your event handler to true.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Close() and Closing()

    OK, thats great, just what the doctor ordered Thanks for the quick reply guys!
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width