表单keyDown无法正常工作? [英] Form keyDown not working?

查看:101
本文介绍了表单keyDown无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.Control Then
        MessageBox.Show("aaaa")
    End If
End Sub

如您所见,我的表单将在按下控制键时进行检查. 但这是行不通的.为什么?

As you can see, my form will check for when the control key is pressed down. But it doesn't work. Why?

推荐答案

我现在不在电脑旁,因此无法测试,但是当我想以前在表单上获取关键事件时,可以设置Form1 .KeyPreview为True(或类似名称).

I am not near a computer now so I can't test this, but when I have wanted to get key events on a form before, I would set Form1.KeyPreview to True (or something similar).

这篇关于表单keyDown无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆