如何让lable控件沿窗体四周运动一圈
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace yundng
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double myWidth = this.ClientSize.Width;
double myHeight = this.ClientSize.Height;
int j = 0;
int k = 0;
while (j<myWidth)
{
label1.Location = new Point(label1.Location.X + 1, label1.Location.Y);
j++;
}
while (k<myHeight)
{
label1.Location = new Point(label1.Location.X, label1.Location.Y +1);
k++;
}
while (j>0)
{
label1.Location = new Point(label1.Location.X - 1, label1.Location.Y);
j--;
}
while (k > 0)
{
label1.Location = new Point(label1.Location.X, label1.Location.Y - 1);
k--;
}
}
}
这样写的话,代码错在哪?