System.Windows.Forms.Control.Enter Event

Occurs when the control is entered.

Syntax

public event EventHandler Enter

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.

Note:

The Control.Enter and Control.Leave events are suppressed by the System.Windows.Forms.Form class. The equivalent events in the System.Windows.Forms.Form class are the Form.Activated and Form.Deactivate events. The Control.Enter and Control.Leave events are hierarchical and will cascade up and down the parent chain until the appropriate control is reached. For example, assume you have a System.Windows.Forms.Form with two System.Windows.Forms.GroupBox controls, and each System.Windows.Forms.GroupBox control has one System.Windows.Forms.TextBox control. When the caret is moved from one System.Windows.Forms.TextBox to the other, the Control.Leave event is raised for the System.Windows.Forms.TextBox and System.Windows.Forms.GroupBox, and the Control.Enter event is raised for the other System.Windows.Forms.GroupBox and System.Windows.Forms.TextBox.

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