|
-
Mar 26th, 2007, 08:49 PM
#1
Thread Starter
Junior Member
[2005][Resolved] Toolstrip Shorcut Question
Okay, I have a tool strip and it has a shortcut for a button.
Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Me.KeyPreview = True
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
Go1.PerformClick()
End If
End Sub
But when the program first loads I have to press on the main form to make the shortcut be able to be used. How can I get around this?
Thank you,
Adam
Last edited by admeech29; Mar 26th, 2007 at 10:48 PM.
-
Mar 26th, 2007, 10:17 PM
#2
Re: [2005] Toolstrip Shorcut Question
This is not a new topic and should have been added to your previous thread. You should be setting the KeyPreview property of the form to True in the designer. The whole point of setting KeyPreview to True is so that the form will receive all keybourd events. If you wait until a keyboard event is received to set the property to True then you will have already missed some keyboard events. In your previous thread I posted this:
Set the form's KeyPreview property to True, handle the KeyDown event
implying that the property is set first, not inside the event handler.
-
Mar 26th, 2007, 10:42 PM
#3
Re: [2005] Toolstrip Shorcut Question
Please ask your questions on the forum, not in personal messages, particularly if you already have a thread dedicated to the topic.
Open your form in the designer, open the Properties window, set the KeyPreview property to True.
-
Mar 26th, 2007, 10:48 PM
#4
Thread Starter
Junior Member
Re: [2005] Toolstrip Shorcut Question
Thank you very much. It worked perfect.
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
|