如何为表单按钮使用快捷键. [英] How to use shortcut keys for button of forms.
本文介绍了如何为表单按钮使用快捷键.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对表单上使用的按钮使用快捷键.
例如,我想在按下键盘上的Esc键时关闭窗体.
如果有任何对此有代码的人请转发.
预先感谢.
I want to use shortcut keys for button used on forms.
for example i want to close form on key press of Esc button on keyboard.
if any one having code for this pls forward it.
Thanks in advance.
推荐答案
HJi,
将此代码复制到您的代码中:
HJi,
copy this code to your code:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Escape) this.Close();
return base.ProcessCmdKey(ref msg, keyData);
}
在窗体键按下事件中写入此
如果(e.keycode == keys.escape)
{
this.close
}
on form key down event write this
if (e.keycode == keys.escape)
{
this.close
}
这篇关于如何为表单按钮使用快捷键.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文