标签:
private void button1_Click(object sender, EventArgs e) { int recordx = this.Left; //指定窗体左边值 int recordy = this.Top; //指定窗体上边值 for (int i = 0; i < 10; i++) //抖动次数 { if (i % 2 == 0) //如果i 能给2整除 { this.Left = this.Left + 10; //窗体左边值加10 } else //否则 { this.Left = this.Left - 10;//窗体左边边值减10 } if (i % 2 == 0)//如果i能给2整除 { this.Top = this.Top + 10;//窗体上边值加10 } else//否则 { this.Top = this.Top - 10;//窗体上边值减10 } System.Threading.Thread.Sleep(30); //震动频率 } this.Left = recordx; //恢复初始状态 this.Top = recordy; <span style="font-family: Arial, Helvetica, sans-serif;">//</span><span style="font-family: Arial, Helvetica, sans-serif;">恢复初始状态</span> }
标签:
原文地址:http://blog.csdn.net/ilipan/article/details/45934965