tags:

views:

15

answers:

1

how to create shorcut key in toolbar or shortcut to call both procedure or function

A: 

To have your form catch keyboard shortcuts, use something like this

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' When the form loads, the KeyPreview property is set to True.
        ' This lets the form capture keyboard events before
        ' any other element in the form.
        Me.KeyPreview = True
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.Alt And e.KeyCode.ToString = "F" Then
            ' When the user presses both the 'ALT' key and 'F' key,
            ' KeyPreview is set to False, and a message appears.
            ' This message is only displayed when KeyPreview is set to True.
            Me.KeyPreview = False
            MsgBox("KeyPreview is True, and this is from the FORM.")
        End If
    End Sub

See http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx for more keys

Lerxst
how about if i want to use Ctrl??i dnt found it
leonita
Look at the KeyEventArgs class. e.Control is what you want. See my edit for more info
Lerxst