在keyDown事件中不能捕获上,下,左,右的方向键,需要重写ProcessDialogKey事件,如下:
/*键盘事件*/
protected override bool ProcessDialogKey(Keys keyData)
{
MessageBox.Show(keyData.ToString());
protected override bool ProcessDialogKey(Keys keyData)
{
MessageBox.Show(keyData.ToString());
if (keyData == Keys.Up || keyData == Keys.Down || keyData == Keys.Left || keyData == Keys.Right)
return false;
else
return base.ProcessDialogKey(keyData);
}