如何捕捉一个C#.NET窗体上的一个键preSS [英] How to catch a key press on a C# .NET form

查看:97
本文介绍了如何捕捉一个C#.NET窗体上的一个键preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大量的控件父窗体。我所试图做的是过滤所有的关键presses的这种形式。麻烦的是,如果关注的是形式,然后父窗体没有拿到钥匙preSS事件上的控件之一,所以我怎么捕获键按下事件?

I have a parent form that contains a lot of controls. What I am trying to do is filter all of the key presses for that form. The trouble is that if the focus is on one of the controls on the form then the parent form is not getting the key press event, so how do I capture the key down event?

推荐答案

设置关键点preVIEW到表单中,你会赶上他们在正确的:<一href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.key$p$pview%28VS.71%29.aspx">MSDN

Set KeyPreview to true on your form and you will catch them: MSDN

这篇关于如何捕捉一个C#.NET窗体上的一个键preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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