Export (0) Print
Expand All

PrintPreviewDialog.KeyPreview Property

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.

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

[BrowsableAttribute(false)]
public bool KeyPreview { get; set; }

Property Value

Type: System.Boolean
true if the form will receive all key events; false if the currently selected control on the form receives key events. The default is false.

This property is not relevant for this class.

When this property is set to true, the form will receive all KeyPress, KeyDown, and KeyUp events. After the form's event handlers have completed processing the keystroke, the keystroke is then assigned to the control with focus.

You can use this property to process all keystrokes in your application and either handle the keystroke or call the appropriate control to handle the keystroke. For example, when an application uses function keys, you might want to process the keystrokes at the form level rather than writing code for each control that might receive keystroke events.

NoteNote:

If a form has no visible or enabled controls, it automatically receives all keyboard events.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft