private void timer1_Tick(object sender, EventArgs e)//时钟事件
{
Label lab = new Label();
Random rm = new Random();
int result = rm.Next(0 ,this.Width);
int aTz = rm.Next(65,91);
lab.AutoSize = true;
lab.Location = new System.Drawing.Point(result,0);
lab.Name = Convert.ToChar(result).ToString();
//lab.Size = new System.Drawing.Size(41, 12);
lab.Text = Convert.ToChar(aTz).ToString();
lab.Font = new Font( "新宋体 ",13);
lab.ForeColor = Color.Blue;
this.Controls.Add(lab);
//
Thread labelThread = new Thread(new ThreadStart(new MoveChar(lab,this).Move));
labelThread.Start();
}
public class MoveChar
{
private Label labTeam;
private Form formlab;
public MoveChar(Label lab, Form form)
{
labTeam = lab;
formlab = form;
}
public void Move()
{
while (true)
{
Thread.Sleep(100);
Invoke(new MethodInvoker(mm));//当前上下文中不存在名称 "Invoke "
if (this.labTeam.Top > = 800)
{
//this.labTeam.Visible = false;
this.labTeam.Dispose();
Thread.CurrentThread.Abort();
break;
}
}
}
public void mm()
{
this.labTeam.Top += 3;
}
http://topic.csdn.net/u/20070608/11/d4098716-2718-432e-bacd-d10b6e75968c.html