KeyPressEventArgs.Handled Property


Gets or sets a value indicating whether the KeyPress 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 if the event is handled; otherwise, false.

If the event is not handled, it will be sent to the operating system for default processing. Set Handled to true to cancel the KeyPress event.

The following example creates a TextBox control. The keypressed method uses the KeyChar property to check whether the ENTER key is pressed. If the ENTER key is pressed, the Handled property is set to true, which indicates the event is handled.

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

.NET Framework
Available since 1.1
Return to top