|
-
Jul 19th, 2003, 11:21 AM
#1
Thread Starter
New Member
Keypress & Keydown Event Handling
I am new to VB.Net and would like to create keystroke event handling at the Form level. I understand that the Form's KeyPreview property must be set to True. I want to intercept the <Enter> key even when Button objects are on the form. I create two event handlers within the form's code something like this:
Sub KPress(ByVal o as Object, ByVal e as KeyPressEventArgs) Handles MyBase.KeyPress
e.Handled = True
msgbox("Form Intercepted the KeyPress")
End Sub
and
Sub KDown(ByVal o as Object, ByVal e as KeyEventArgs) Handles MyBase.KeyDown
e.Handled = True
msgbox("Form Intercepted the KeyDown")
End Sub
However, when a Button has the Focus, the Button's Click event handles the keystroke, not the Form.
Thanks for your help...in advance,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|