private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Left)
{
GetChange(“Left”);
}
else if(e.KeyCode == Keys.Right)
{
GetChange(“Right”);
}
else if (e.KeyCode == Keys.Up)
{
GetChange(“Upper”);
}
else if (e.KeyCode == Keys.Down)
{
GetChange(“Down”);
}
}
{
if(e.KeyCode == Keys.Left)
{
GetChange(“Left”);
}
else if(e.KeyCode == Keys.Right)
{
GetChange(“Right”);
}
else if (e.KeyCode == Keys.Up)
{
GetChange(“Upper”);
}
else if (e.KeyCode == Keys.Down)
{
GetChange(“Down”);
}
}
解决方案
40
窗体的KeyPreview属性设为true。