建议在Form里重写ProcessKeyPreview方法实现你的需求,看是否可以?
- Protected Overrides Function ProcessKeyPreview(ByRef m As Message) As Boolean
- Dim WM_KEYDOWN As Integer = 256
- If m.Msg = WM_KEYDOWN Then
- '115 is F4
- If (CInt(m.WParam) = 115) Then
- Me.txt.Focus()
- Return True
- End If
- End If
- Return MyBase.ProcessKeyPreview(m)
- End Function
复制代码 |