在C#(Microsoft Visual Studio 2010)中,如何将键盘快捷键分配给如下所示的按钮?
private void closeButton_Click(object sender, EventArgs e)
{
// Close the program
this.Close();
}
我知道我可以在按钮的文本中使用“&”字符并创建一个Alt- n快捷键,但是我想创建一个按键快捷键,例如c执行上述操作。
发布于 2018-05-07 13:15:02
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch(keyData)
{
case Keys.F2:
// do something...
return true;
case Keys.F3:
// do something...
return true;
case Keys.F4:
// do something...
return true;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
}
https://stackoverflow.com/questions/-100008380
复制相似问题