Setting e.Handled in the KeyDown event has no effect in Visual Basic .NET or in Visual Basic 2005 (326442)
The information in this article applies to:
- Microsoft Visual Basic 2005 Express Edition
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
This article was previously published under Q326442 SYMPTOMS
When you handle the KeyDown event in a Windows Form control, alphanumeric keystrokes are still processed after you set the e.Handled argument to True.
CAUSE
The KeyDown event is not designed to handle alphanumeric keystrokes. Although the KeyDown event fires when an alphanumeric key is pressed, you can only use the KeyDown event to determine information about what key was pressed. This event does not stop an alphanumeric keystroke from being processed.
Non-alphanumeric keystrokes (such as the arrow keys, the HOME key, the END key, and the DELETE key) can be handled during the KeyDown event.
RESOLUTION
To resolve this problem, use the KeyPress event instead of the KeyDown event if you have to handle alphanumeric keystrokes.
STATUSThis behavior is by design.REFERENCESFor additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
320583 HOW TO: Trap Keystrokes in .NET Controls by Using Visual Basic .NET
| Modification Type: | Major | Last Reviewed: | 2/8/2006 |
|---|
| Keywords: | kbtshoot kbvs2005applies kbvs2005swept kbprb KB326442 |
|---|
|