在Windows应用程序中使用功能键 [英] Use Function Keys in Windows application
本文介绍了在Windows应用程序中使用功能键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Windows应用程序中使用功能键(C#)。
解决方案
private void < Control> _KeyDown( object sender,KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys .F1:
break ;
case Keys.F10:
break ;
case Keys.F11:
break ;
case Keys.F12:
break ;
默认:
break ;
}
}
这可能对你有帮助。
http://stackoverflow.com/questions/1707040/handling-function-key-press [ ^ ]
您好,
您可以在Windows应用程序中使用FunctionKeys作为快捷方式。只需为您的控件编写一个KeyDown事件,然后匹配按下的键
例如
< span class =code-keyword> if (e.KeyValue > = 112 && e.KeyValue < = 123 )
{
MessageBox .Show( 你按下F +(e.KeyValue - 111 跨度>)的ToString());
}
或
private void textBox1_KeyDown( object sender,KeyEventArgs e)
{
if (e .KeyCode == Keys.Enter)
{MessageBox.Show( 输入按键 ); }
}
希望这有帮助!! :)
问候,
Praneet
在表单加载事件中,请尝试如下:
private void Form1_Load( object sender,EventArgs e)
{
this < /跨度> .Focus();
此 .KeyPreview = true ;
this .KeyDown + = new KeyEventHandler(Form1_KeyDown);
}
void Form1_KeyDown( object sender,KeyEventArgs e)
{
// 你的逻辑在这里
}
希望这会有所帮助!!
问候,
Praneet
How to Use Function Keys in Windows application (C#).
解决方案
private void <Control>_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.F1: break; case Keys.F10: break; case Keys.F11: break; case Keys.F12: break; default: break; } }
this might help you.
http://stackoverflow.com/questions/1707040/handling-function-key-press[^]
Hi,
You can use FunctionKeys as shortcuts in your windows application. Just write a KeyDown event for your control and then you match the pressed key
For e.g
if (e.KeyValue >= 112 && e.KeyValue <= 123) { MessageBox.Show("You pressed F" + (e.KeyValue - 111).ToString()); } or private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { MessageBox.Show("Enter key pressed"); } }
Hope this helps !! :)
Regards,
Praneet
Hi,
In your form Load event, try it like this:
private void Form1_Load(object sender, EventArgs e) { this.Focus(); this.KeyPreview = true; this.KeyDown += new KeyEventHandler(Form1_KeyDown); } void Form1_KeyDown(object sender, KeyEventArgs e) { // Your logic goes here }
Hope this helps !!
Regards,
Praneet
这篇关于在Windows应用程序中使用功能键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文