Redigeeri

Jagamisviis:


PrintPreviewDialog.KeyPreview Property

Definition

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

public:
 property bool KeyPreview { bool get(); void set(bool value); };
[System.ComponentModel.Browsable(false)]
public bool KeyPreview { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.KeyPreview : bool with get, set
Public Property KeyPreview As Boolean

Property Value

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.

Attributes

Remarks

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.

Note

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

Applies to