如何制作三个同时移动的图片框?

时间:2016-04-14 07:55:11

标签: c# winforms

我有3个图片盒(boardTop,boardCenter,boardBottom)。按下向上箭头或向下箭头键时,我希望这三个图片框一起移动。

private void PingPong_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Up)
    {
        boardUp.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
        boardLeft.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
        boardDown.Location = new Point(boardUp.Location.X, boardUp.Location.Y - 1);
        Kup = true;
    }
    else if (e.KeyCode == Keys.Down)
    {
        boardUp.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
        boardLeft.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
        boardDown.Location = new Point(boardUp.Location.X, boardUp.Location.Y + 1);
        Kdown = true;
    }
}

enter image description here

0 个答案:

没有答案