热键(完成某些任务的组合键) [英] hotkey (key combination to do some task)
本文介绍了热键(完成某些任务的组合键)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我有一个空白表格名称form1.我想每当按下(control + n)的组合键时都会显示一条消息(无论如何").
请提及代码
还请告诉我所有键盘的keyChar值是否存在任何链接.
谢谢
Hi all
I have a blank form name form1. I want whenever I press the key combination of (control+n) its shows a message ("whatever").
PLEASE MENTION CODE
Please also tell me if there any link for keyChar value of all keyboard.
Thanks
推荐答案
一个经常被问到的问题...
参见此处 [
A question asked often...
See Here[^]
For Key Chars
for(int i=1; i<=255; i++)
{
char cs=(char) i;
Response.Write(i.ToString() + "--");
Response.Write(cs.ToString() + "<br>");
}
在设计视图中,选择您的Form并转到其属性.选择事件",然后双击"KeyUp".这将为您添加一个事件处理程序.
添加此代码:
In the design view select your Form and go to it''s properties. Select "events" and double click "KeyUp". This will add a event handler for you.
Add this code:
If e.Control = True And e.KeyCode = Keys.N Then
MsgBox("whatever")
End If
希望对您有所帮助:)
Hope this helps :)
您可以在keydown事件中获取它.
You can get it in keydown event.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.N And e.Control Then
MessageBox.Show("Ctrl+N is pressed", "Access Keys")
End If
End Sub
对于空表单,此代码可以,但是在带有控件的表单中,请不要忘记将表单的KeyPreview属性设置为true.
For empty form this code is OK, but in form with controls, don''t forget to set KeyPreview property of form to true.
KeyPreview = True
这篇关于热键(完成某些任务的组合键)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文