Inherited Key Down Event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbruhnsen
    New Member
    • Mar 2007
    • 3

    #1

    Inherited Key Down Event

    I'm try to run som code in a base class to trap the F7 key. However, when I press F7 on an inhereted form, the code never fires. I'm sure I'm missing something simeple. My code in the base class is:

    Public Sub frmBaseForm_Key Down(ByVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles Me.KeyDown

    ' Custom Code Here

    End Sub
  • sbruhnsen
    New Member
    • Mar 2007
    • 3

    #2
    Sorry, this is actualy the code:

    Public Sub frmBaseForm_Key Down(ByVal sender As Object, ByVal e As System.Windows. Forms.KeyEventA rgs) Handles Me.KeyDown

    If e.KeyCode = Keys.F7 Then

    end if

    end sub

    Comment

    • sbruhnsen
      New Member
      • Mar 2007
      • 3

      #3
      I found the problem. It's the ProcessCmdKey that has to be overriding. You must also give it a return call.


      Protected Overrides Function ProcessCmdKey(B yRef msg As System.Windows. Forms.Message, ByVal keyData As System.Windows. Forms.Keys) As Boolean
      If keyData = Keys.F7 Then
      Return MyBase.ProcessC mdKey(msg, keyData)
      End Function

      Comment

      Working...