向下移动一个对象,C#

时间:2013-12-12 22:44:04

标签: c# winforms

我按下按钮可以向上移动一个物体。我只是想知道我必须改变什么才能让它向下移动(不同的按钮)

private void CP_GFButton_Click(object sender, EventArgs e)
        {
            while (LDoor.Location.Y < 0)
                while (Rdoor.Location.Y < 0)
                {
                    LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y - 1);
                    System.Threading.Thread.Sleep(10);

                    Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y - 1);
                    System.Threading.Thread.Sleep(10);
                }
        }

1 个答案:

答案 0 :(得分:0)

        while (LDoor.Location.Y < MaxVal)
            while (Rdoor.Location.Y < MaxVal)
            {
                LDoor.Location = new System.Drawing.Point(LDoor.Location.X, LDoor.Location.Y + 1);
                System.Threading.Thread.Sleep(10);

                Rdoor.Location = new System.Drawing.Point(Rdoor.Location.X, Rdoor.Location.Y + 1);
                System.Threading.Thread.Sleep(10);
            }