Community-Credit.com | NonProfitWays.com | SOAPitstop.com   Skin:   
      User: Not logged in 
Home
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Presentations
Featured Articles
Book Chapters
Training Courses
Events
NewsGroups
 
Discussions
Examples
Tutorials
Tools
Articles
Resources
Websites
 
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
Logout
 
About Me
My Blog
HeadGeek Articles
Talking Portfolio
Resume
Pictures
World Trip Pics

Windows forms event firing order mystery an hysteria, or "mysteria"
Author: Duray AKAR
Published: 3/22/2006 5:59 AM
Category: C#, VS.NET
Summary: I needed to solve the mystery of winforms event firing order, and here is what I did...

 

I created a form, and a user control with a public string TestProperty.

I decorated both of them with eventhandlers and debug text like :

Debug.Print(this.ToString() + ":Load");

Then dropped 2 of my usercontrols on this form, each on a separate tab in a tab control.

In the load eventhandler of the form, I set the TestProperty of both the user controls...

So the event handler code looks like :

private void TestForm_Load(object sender, EventArgs e)

{

Debug.Print(this.ToString() + " : " +"Load");

this.FirstControl.TestProperty = "This is it";

this.SecondControl.TestProperty = "This is not it";

}

 

I run the application, click a button to create and show the form, and close the form opened.

 

Here is what happens behind the scenes in runtime.

 

 

WinFormsEvents.TestForm, Text: : before InitializeComponent

WinFormsEvents.TestControl : BeforeInitializeComponent

WinFormsEvents.TestControl : AfterInitializeComponent

WinFormsEvents.TestControl : BeforeInitializeComponent

WinFormsEvents.TestControl : AfterInitializeComponent

WinFormsEvents.TestControl:UserControl1_VisibleChanged

WinFormsEvents.TestControl:Layout

WinFormsEvents.TestControl:OnTestPropertyChanged

WinFormsEvents.TestControl:UserControl1_VisibleChanged

WinFormsEvents.TestControl:Layout

WinFormsEvents.TestControl:OnTestPropertyChanged

WinFormsEvents.TestForm, Text: TestForm : Layout

WinFormsEvents.TestForm, Text: TestForm : after InitializeComponent

Form Number 0 Property Set

WinFormsEvents.TestControl:Layout

WinFormsEvents.TestControl:Load

WinFormsEvents.TestControl:Layout

WinFormsEvents.TestControl:UserControl1_VisibleChanged

WinFormsEvents.TestForm, Text: Form Number 0 : Load

WinFormsEvents.TestControl:OnTestPropertyChanged

WinFormsEvents.TestForm, Text: Form Number 0 : WinFormsEvents.TestControl : TestPropertyChanged

WinFormsEvents.TestControl:OnTestPropertyChanged

WinFormsEvents.TestForm, Text: Form Number 0 : WinFormsEvents.TestControl : TestPropertyChanged

WinFormsEvents.TestForm, Text: Form Number 0 : Layout

WinFormsEvents.TestForm, Text: Form Number 0 : VisibleChanged

WinFormsEvents.TestControl:Layout

WinFormsEvents.TestControl:UserControl1_VisibleChanged

WinFormsEvents.TestForm, Text: Form Number 0 : Activated

WinFormsEvents.TestForm, Text: Form Number 0 : Deactivate

WinFormsEvents.TestForm, Text: Form Number 0 : Activated

WinFormsEvents.TestForm, Text: Form Number 0 : FormClosing

WinFormsEvents.TestForm, Text: Form Number 0 : FormClosed

WinFormsEvents.TestForm, Text: Form Number 0 : Deactivate

One of the forms are Disposed


 

 
Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”



Advertise on XMLPitstop

Advertise on XMLPitstop


EggHead Cafe
Web Servicee development
DotNetSlackers
Buy text ads here!
internet server backup
Color Laser Printer
online business degree
Versace sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,219 Total Members
34 members(last 30 days)
5 members(last 7 days)
0 members(today)

1,609 Total Discussions
14 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,106 Total Blog Posts
1,771 Blogs(last 30 days)
235 Blogs(last 7 days)
0 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,785 Total Resources
4 Resources(last 30 days)
0 Resources(last 7 days)
0 Resources(today)


 

David Silverlight's XMLPitstop.com| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139