Handled Property

KeyEventArgs.Handled Property

 

Gets or sets a value indicating whether the event was handled.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member Handled : bool with get, set

Property Value

Type: System.Boolean

true to bypass the control's default handling; otherwise, false to also pass the event along to the default control handler.

Handled is implemented differently by different controls within Windows Forms. For controls like TextBox which subclass native Win32 controls, it is interpreted to mean that the key message should not be passed to the underlying native control. If you set Handled to true on a TextBox, that control will not pass the key press events to the underlying Win32 text box control, but it will still display the characters that the user typed.

If you want to prevent the current control from receiving a key press, use the SuppressKeyPress property.

The following example determines whether the user pressed a non-numeric key, and if so, cancels the KeyPress event by using the Handled property.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft