System.Windows.Forms.Control.LostFocus Event

Occurs when the control loses focus.

Syntax

[System.ComponentModel.Browsable(false)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
public event EventHandler LostFocus

Remarks

When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Control.Select or Control.SelectNextControl(Control, bool, bool, bool, bool) methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

When you change the focus by using the mouse or by calling the Control.Focus method, focus events occur in the following order:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

If the Control.CausesValidation property is set to false, the Control.Validating and Control.Validated events are suppressed.

If the System.ComponentModel.CancelEventArgs.Cancel property of the System.ComponentModel.CancelEventArgs is set to true in the Control.Validating event delegate, all events that would usually occur after the Control.Validating event are suppressed.

Note:

The Control.GotFocus and Control.LostFocus events are low-level focus events that are tied to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the Control.GotFocus and Control.LostFocus events are only used when updating System.Windows.Forms.UICues or when writing custom controls. Instead the Control.Enter and Control.Leave events should be used for all controls except the System.Windows.Forms.Form class, which uses the Form.Activated and Form.Deactivate events. For more information about the Control.GotFocus and Control.LostFocus events, see the WM_SETFOCUS and WM_KILLFOCUS topics in the "Keyboard Input Reference" section in the MSDN library at http://msdn.microsoft.com/library.

Note:

Do not attempt to set focus from within the Control.Enter, Control.GotFocus, Control.Leave, Control.LostFocus, Control.Validating, or Control.Validated event handlers. Doing so can cause your application or the operating system to stop responding. For more information, see the WM_KILLFOCUS topic in the "Keyboard Input Reference" section, and the "Message Deadlocks" section of the "About Messages and Message Queues" topic in the MSDN library at http://msdn.microsoft.com/library.

For more information about handling events, see Consuming Events.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0