Using one of the F keys to trigger an event
-
Thursday, December 04, 2008 2:36 PM
Is there a way to trigger an event when the end user presses one of the F keys? For instance I am already using one of my buttons as the Acceptbutton. What I would like to do is if the user presses say F11 it will trigger another button on my form and run the code. Any suggestions? I am using C#
All Replies
-
Thursday, December 04, 2008 2:46 PM
Hi Marty,
Here is your solution.
Set KeyPreview = True of Form.
Then in KeyDown Event of Form write following code.
Code SnippetPrivate Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Try
If e.KeyCode = Keys.F11 Then
"Function 1") '''''Here you can write your own code.MsgBox(
End If
Catch ex As Exception End Try End SubIf your requirement is different or if i misunderestood then let me know.
Thank You
Best Regards
Utkarsh Gajjar.
-
Thursday, December 04, 2008 3:04 PM
Marty Q wrote: Is there a way to trigger an event when the end user presses one of the F keys? For instance I am already using one of my buttons as the Acceptbutton. What I would like to do is if the user presses say F11 it will trigger another button on my form and run the code. Any suggestions? I am using C#
Duplicate post.
-
Thursday, December 04, 2008 3:30 PM
You are good. That worked perfectly thanks.


