Sticky question

What's the best technique used to see all the events and the order in which they execute during the life of a winform carrying labels, textboxes, checkboxes, and dropdownlists, etc  Thanks. 


Answer this question

Sticky question

  • jlkyle

    I appreciate your detailed explanation. Please kindly provide sample code on setting up event handlers for all of the Form events and writing out to a debug console the events as they are fired. Is there a way to set Console.Write to a text file  I remember seeing how that 's done in a MSDN article but don't recall where now off the top of my head. Thanks so much.

  • IamLost

    Hi,

    Are you suggesting that Validating and Validated events never fire on a form

    That is the behavior I am getting as of now, even I Call Form.Validate()

    I can call ValidateChildren() and force all children to validate, but still Form.Validating and Form.Validated Events does not fire...

     

    Thank you

     



  • Divyesh Shah


    To do this, you'll be interested in learning more about the Debug and Trace classes and associated functionality. By default, this information will be printed to the debug console but you may also write this information to other locations, such as a text file.

    Here is an example usage:

    private void Form_Load(object sender, EventArgs e)
    {
       Debug.WriteLine("Form_Load called.");
    }

    To output the debug/trace information to a text file, see the following:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbcon/html/vxtskCreatingInitializingTraceListeners.asp

    You can also configure listeners in your app.config file, too.

    Hope that helps,
    -Paul

  • Brain_Dead_Mind

    The best source for this information is MSDN help. For example, here is the sequence of events that are fired in the event lifecycle of a form:

    - Construtor
    - Load
    - Layout
    - Activated
    - Paint­
    - Closing
    - Closed
    - Deactivate
    - Dispose

    and for controls:

    - Enter 
    - GotFocus 
    - Leave 
    - Validating 
    - Validated 
    - LostFocus

    For bonus points, you might also want to set up event handlers for all of the Form events and write out to your debug console the events as they are fired.

    -Paul

  • Sticky question