using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace app1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
// 
// label1
// 
this.label1.BackColor = System.Drawing.SystemColors.Desktop;
this.label1.Font = new System.Drawing.Font("楷体_GB2312", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(64, 344);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 0;
this.label1.Text = "开始";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);
// 
// label2
// 
this.label2.BackColor = System.Drawing.SystemColors.Desktop;
this.label2.Font = new System.Drawing.Font("楷体_GB2312", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(176, 344);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 1;
this.label2.Text = "暂停";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label2_MouseUp);
this.label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label2_MouseDown);
// 
// groupBox1
// 
this.groupBox1.Location = new System.Drawing.Point(0, 332);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(376, 2);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
// 
// timer1
// 
this.timer1.Enabled = true;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.ClientSize = new System.Drawing.Size(312, 373);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
} private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.label1.Top+=2;
this.label1.Left+=2;
show2 z=new show2();
this.Controls.Add(z.x);

} private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.label1.Top-=2;
this.label1.Left-=2;
} private void label2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.label2.Top+=2;
this.label2.Left+=2;
} private void label2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.label2.Top-=2;
this.label2.Left-=2;
} private void timer1_Tick(object sender, System.EventArgs e)
{

}

}
}
namespace app1
{
class labelone:Control
{
System.Windows.Forms.Label x;
private static int z=10;
System.Timers.Timer tmr;
public labelone()
{
show();
}
public Label show()
{

tmr=new System.Timers.Timer(1000);
tmr.Enabled=true;
tmr.Elapsed+=new System.Timers.ElapsedEventHandler(tmr_Elapsed);

System.Random r=new Random();
char c=(char)r.Next(65,91);

x=new Label();
x.Top=0;
x.Left=r.Next(0,130);
x.BackColor = System.Drawing.SystemColors.Desktop;
x.Font = new System.Drawing.Font("楷体_GB2312", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
x.Name = "label1";
x.Size = new System.Drawing.Size(40, 40);

x.Text = c.ToString();
x.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
return x;
} private void tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
 this.x.Top+=z;
}
}
}
namespace app1{
class show2{
   public System.Windows.Forms.Label x;
System.Timers.Timer tm;
public show2(){
tm=new System.Timers.Timer(1000);
tm.Enabled=true;
tm.Elapsed+=new System.Timers.ElapsedEventHandler(tm_Elapsed);
}
private void tm_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
labelone show1=new labelone();
 Label x=show1.show();
}

}
}我在第二个类中用了个做了个LABLE 下落的效果
用第一个类直接用能行。
我在第三个类中调用第二个类为了就为了产生多个LABLE
在第一个类中实现
这代码出现的情况就是看不到LABEL了
没添加进去
求高手指教