c# winform快捷键设置
设置 Form 的 KeyPreview=true 然后在Form 的案件事件里判断按钮类型进行分别调用就可以了
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (!ListViewModel)
{
if (e.Control)
{
switch (e.KeyCode)
{
case Keys.A:
addTSB.PerformClick();
break;
case Keys.S:
saveTSB.PerformClick();
break;
case Keys.D:
delTSB.PerformClick();
break;
case Keys.R:
redoTSB.PerformClick();
break;
case Keys.P:
createDocTSB.PerformClick();
break;
case Keys.F:
findTSB.PerformClick();
break;
default:
break;
}
e.Handled = true;
}
}
}
本文来自博客园,作者:NLazyo,转载请注明原文链接:https://www.cnblogs.com/bile/p/3369818.html