469,621 Members | 1,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

KeyDown Event in VB 2005


I have a VB 2005 windows app and I want to recognize keydown events. I have
a form key down event handler but it does not get control when a key is
depressed. In playing around I found that if I add a keydown event handler
for some control on the form, say a textbox ...
Private Sub txtBox_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtBox.KeyDown)

and then give that control focus the keydown event is recognized by that
handler. My question is how to I set things up so that when the app is
launched and the user presses a key it will be seen by the form's keydown
event handler.

Thanks.


Mar 4 '06 #1
1 3071
fripper,

If you set the form's KeyPreview property to True you get a first shot at
processing all the form's keystrokes.

Kerry Moorman
"fripper" wrote:

I have a VB 2005 windows app and I want to recognize keydown events. I have
a form key down event handler but it does not get control when a key is
depressed. In playing around I found that if I add a keydown event handler
for some control on the form, say a textbox ...
Private Sub txtBox_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtBox.KeyDown)

and then give that control focus the keydown event is recognized by that
handler. My question is how to I set things up so that when the app is
launched and the user presses a key it will be seen by the form's keydown
event handler.

Thanks.



Mar 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by bardo | last post: by
4 posts views Thread by Tony | last post: by
4 posts views Thread by Anne | last post: by
4 posts views Thread by ShaneO | last post: by
3 posts views Thread by MLM450 | last post: by
5 posts views Thread by T | last post: by
3 posts views Thread by win | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.