我有3个控件 - NumericUpDown的子类形式。
这是主要形式'代码:
Public Class Form1
Inherits cls_subform
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
End Sub
Private Sub NumericUpDown1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NumericUpDown1.KeyDown
If e.KeyCode = Keys.Enter Then
Debug.Print "Control's ENTER is pressed"
End If
End Sub
End Class
这是简化的frm_subform代码:
Public Class cls_subform
Inherits System.Windows.Forms.Form
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Sub onKeyDown(ByVal e As System.Windows.Forms.KeyEventArgs)
If e.KeyCode = Keys.Enter Then
e.Handled = True
e.SuppressKeyPress = True
Debug.Print "Subclassed ENTER is pressed"
End If
MyBase.OnKeyDown(e)
End Sub
End Class
这显然是工作的目标 但问题是我想处理控件的事件处理程序NumericUpDown1_KeyDown FIRST。然后,如果它没有“处理”,我想在frm_subform上处理onKeyDown事件处理程序 如果我将KeyPreview设置为False,那么我可以捕获控件的事件但是不会触发onKeyDown。
有没有办法获得所需的功能?
FIRST将被触发控件的_KeyDown处理程序,然后形成onKeyDown处理程序?