调用这个方法试试:
private void Play()
{
int leftWidth = this.Left; //指定窗体左边值
int topWidth = this.Top; //指定窗体上边值
for (int i = 0; i < 20; i++)
{
if (i % 2 == 0)
{
this.Left = this.Left + 10;
}
else //否则
{
this.Left = this.Left - 10;
}
if (i % 2 == 0)
{
this.Top = this.Top + 10;
}
else//否则
{
this.Top = this.Top - 10;
}
System.Threading.Thread.Sleep(30);//震动频率
}
this.Left = leftWidth;//重设窗体初此左边值
this.Top = topWidth; //重设窗体初此上边值
}
private void Play()
{
int leftWidth = this.Left; //指定窗体左边值
int topWidth = this.Top; //指定窗体上边值
for (int i = 0; i < 20; i++)
{
if (i % 2 == 0)
{
this.Left = this.Left + 10;
}
else //否则
{
this.Left = this.Left - 10;
}
if (i % 2 == 0)
{
this.Top = this.Top + 10;
}
else//否则
{
this.Top = this.Top - 10;
}
System.Threading.Thread.Sleep(30);//震动频率
}
this.Left = leftWidth;//重设窗体初此左边值
this.Top = topWidth; //重设窗体初此上边值
}