KeyPress的解释是:
Occurs when a character. space or backspace key is pressed while the control has focus.方向键不是character, space或者backspace,因此不fire很好理解。但是我自己试了下keydown也不fire, 我测试的是form, 你可以试一试其它control. 按理说可以。
最后我是使用这种方法
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Left)
{
MessageBox.Show("You pressed Left arrow key");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
参考:
http://stackoverflow.com/questions/13163447/detecting-arrows-keys-in-winforms
Occurs when a character. space or backspace key is pressed while the control has focus.方向键不是character, space或者backspace,因此不fire很好理解。但是我自己试了下keydown也不fire, 我测试的是form, 你可以试一试其它control. 按理说可以。
最后我是使用这种方法
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Left)
{
MessageBox.Show("You pressed Left arrow key");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
参考:
http://stackoverflow.com/questions/13163447/detecting-arrows-keys-in-winforms
解决方案 »
- 面试问题:
- 比如一个按钮控件,名称为 button1,我先写出了单击事件代码,可是之后我再给按钮改名为cmdexit。发现单击事件还是 button1_click,为什么
- [Oracle]如何得到更新行数的问题
- DATASET是否必须实例化?
- 找高手,详细给我指点下把,谢谢!!!!!
- 请问在hashtable里面如何不用foreach遍历
- 怎么检测软件是否被修改过
- 基于XML的电子病历智能推荐功能
- 对于不返回任何键列信息的 SelectCommand 不支持 UpdateCommand 的动态 SQL 生成
- 如何作一个图文combobox?
- 服务器端和客户端分离,怎么引用?
- 对于绑定数据源的datagridview如何实时更新数据
为了养成良好习惯最好用if else 或 switch