Initial winforms content migrated (#18)

* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
This commit is contained in:
Andy De George
2020-09-01 16:26:21 -07:00
committed by GitHub
parent 1a27c9b107
commit c0ba284473
1557 changed files with 129980 additions and 13 deletions
@@ -0,0 +1,80 @@
---
title: "Order of Events"
description: Learn details regarding the order of events in Windows Forms during several important stages in the lifetime of applications and controls.
ms.date: "03/30/2017"
helpviewer_keywords:
- "events [Windows Forms], order of"
- "focus event order"
- "application shutdown event order"
- "sequence [Windows Forms], of events"
- "validation events [Windows Forms], order of"
- "application startup event order"
ms.assetid: e81db09b-4453-437f-b78a-62d7cd5c9829
---
# Order of Events in Windows Forms
The order in which events are raised in Windows Forms applications is of particular interest to developers concerned with handling each of these events in turn. When a situation calls for meticulous handling of events, such as when you are redrawing parts of the form, an awareness of the precise order in which events are raised at run time is necessary. This topic provides some details on the order of events during several important stages in the lifetime of applications and controls. For specific details about the order of mouse input events, see [Mouse Events in Windows Forms](mouse-events-in-windows-forms.md). For an overview of events in Windows Forms, see [Events Overview](events-overview-windows-forms.md). For details about the makeup of event handlers, see [Event Handlers Overview](event-handlers-overview-windows-forms.md).
## Application Startup and Shutdown Events
The <xref:System.Windows.Forms.Form> and <xref:System.Windows.Forms.Control> classes expose a set of events related to application startup and shutdown. When a Windows Forms application starts, the startup events of the main form are raised in the following order:
- <xref:System.Windows.Forms.Control.HandleCreated?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Control.BindingContextChanged?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.Load?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Control.VisibleChanged?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.Activated?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.Shown?displayProperty=nameWithType>
When an application closes, the shutdown events of the main form are raised in the following order:
- <xref:System.Windows.Forms.Form.Closing?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.FormClosing?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.Closed?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.FormClosed?displayProperty=nameWithType>
- <xref:System.Windows.Forms.Form.Deactivate?displayProperty=nameWithType>
The <xref:System.Windows.Forms.Application.ApplicationExit> event of the <xref:System.Windows.Forms.Application> class is raised after the shutdown events of the main form.
> [!NOTE]
> Visual Basic 2005 includes additional application events, such as <xref:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Startup?displayProperty=nameWithType> and <xref:Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Shutdown?displayProperty=nameWithType>.
## Focus and Validation Events
When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the <xref:System.Windows.Forms.Control.Select%2A> or <xref:System.Windows.Forms.Control.SelectNextControl%2A> methods, or by setting the <xref:System.Windows.Forms.ContainerControl.ActiveControl%2A> property to the current form, focus events of the <xref:System.Windows.Forms.Control> class occur in the following order:
- <xref:System.Windows.Forms.Control.Enter>
- <xref:System.Windows.Forms.Control.GotFocus>
- <xref:System.Windows.Forms.Control.Leave>
- <xref:System.Windows.Forms.Control.Validating>
- <xref:System.Windows.Forms.Control.Validated>
- <xref:System.Windows.Forms.Control.LostFocus>
When you change the focus by using the mouse or by calling the <xref:System.Windows.Forms.Control.Focus%2A> method, focus events of the <xref:System.Windows.Forms.Control> class occur in the following order:
- <xref:System.Windows.Forms.Control.Enter>
- <xref:System.Windows.Forms.Control.GotFocus>
- <xref:System.Windows.Forms.Control.LostFocus>
- <xref:System.Windows.Forms.Control.Leave>
- <xref:System.Windows.Forms.Control.Validating>
- <xref:System.Windows.Forms.Control.Validated>
## See also
- [Creating Event Handlers in Windows Forms](creating-event-handlers-in-windows-forms.md)