The X box on a form (close the form)

Posted on 2005-05-17
Last Modified: 2010-04-16
What Event fires when you click on the X in the upper right hand corner of a form?
Question by:knowlton
    LVL 3

    Accepted Solution

    closed event when form is closed.
    And Closing when the form is going to close.

    private void onClosing(object sender, System.ComponentModel.CancelEventArgs e)
          e.Cancel = true;

    OnClosed cannot be canceled.
    LVL 5

    Author Comment

    OnClosing works just fine.

    I wanted to save the Form Height and Form Width before the form I can do this if the X button is clicked!!!

    LVL 5

    Author Comment

    What would be the purpose of OnClosed( )    ?????

    What does it offer me that OnClosing does not ?
    LVL 3

    Expert Comment

    OnClosing can be used to cancel close action, but onClosed cannot be canceled
     undertand it as a option to know if the resources that you were using  has been disposed correctly.

    Basically they are the same thing.

    Closing -->Before Close.
    Closed -->After Closed.
    LVL 5

    Author Comment

    Okay...that helps....thx.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now