// 打字游戏 private void Form1_Load( object sender, EventArgs e) ... { this.timer1.Interval = 500; //定时0.5秒 this.timer1.Start(); //定时启动 } Random r = new Random(); private void timer1_Tick( object sender, EventArgs e) ... { Label l = new Label(); char cc = (char)((int)'A' + r.Next(26)); //随机产生26 个字母 l.Text = cc.ToString(); //l.BackColor = Color.Red; l.ForeColor = Color.Red; l.Left = r.Next(this.Width); //随机水平位置 this.panel1.Controls.Add(l); foreach (Control c in this.panel1.Controls) ...{ c.Top += 15; //向下移动 if (c.Top == this.Height) c.Dispose(); //到底消除 } } private void Form1_KeyDown( object sender, KeyEventArgs e) ... { foreach (Control c in this.panel1.Controls) ...{ if (c.GetType() == typeof(Label)) ...{ Label t = (Label)c; if (t.Text == e.KeyCode.ToString()) //按下的键有, 消除 this.panel1.Controls.Remove(c); } } }