|
-
September 8th, 2011, 07:28 PM
#1
VS 2008: Issue with keydown Space/Enter
Hi guys,
I am using vb.net within visual studio 2008.
I am using a picture box. I want to be able to use the Space or Enter key to change the image in it. For that, I try to use the keydown function as follow:
Private Sub ChestWindow_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Select Case e.KeyCode
Case Keys.NumPad1
NextChest()
Case Keys.Enter
NextChest()
Case Keys.Space
NextChest()
End Select
End Sub
NextChest() is the function which changes the image. It works well when I press '1' on my numeric part of the keyboard as a test.
The issue is that when I press Space or Enter, the form containing the picturebox closes. (I've already put the keyPreview property to True)
I really do not understand. Do these keys have any default behavior? How can I do to make them doing what I want?
Thanks for your help!
Did
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
|