用户控件的KeyDown事件中,不接收方向键,其它键都有反应,请各位指点一下。
KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString());
}
当我按上下左右方向键的时候没反应,其它键没问题
KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString());
}
当我按上下左右方向键的时候没反应,其它键没问题
解决方案 »
- 各路高手求救有谁懂得win7下安装sql2008与vs2008
- 在线等待:自定义DataGridViewColumn控件中自定义属性值无法保存的问题?
- C#菜鸟现金求助!(非常简单的管理程序)
- C# WMI编程 获取手机链接电脑后的那个设备信息
- 谁能帮我解释一下迪杰斯塔拉算法?
- sql语句int型减null的问题
- 问个弱智问题...临时想不起来了,关于字符串的
- 发现最近CSDN的速度比以前快了,不知道是系统升级了还是来的人少了
- 请问程序员大联盟是怎样注册的呀??
- 窗体的问题
- Form 界面假死
- 在WCF中,在客户端如何传List<System.Data.SqlClient.SqlParameter>至WCF服务中,谢谢 急
不行,程序不接收Keys.Down,Keys.Up,Keys.Left,Keys.Right,
Certain keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls automatically. To have these keys raise the KeyDown event, you must override the IsInputKey method in each control on your form. The code for the override of the IsInputKey would need to determine if one of the special keys is pressed and return a value of true.要处理这些键的话override基类的IsInputKey方法即可。
UserControl1 user1= new UserControl1();
panel1.Controls.Add(user1);
panel1.Controls[0].Focus();在用户控件UserControl1里
private void UserControl1_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyCode.ToString());
}
运行后,按方向键不弹出任何提示
{
if (keyData == Keys.Escape)
{
Cursor.Current = Cursors.Default;
Cursor.Show();
this.Close();
return true;
}
return false;
}