int x = 0;
for(int i=0;i<19;i++)
{
Label lb=new Label();
lb.Location=new Point(x,524);
lb.Size= new Size(48,16);
lb.BorderStyle = BorderStyle.Fixed3D;
lb.Name = "Com"+i;
lb.Text = i + "关闭";
this.Controls.Add(lb);
x=x+48;
}
下面的代码中我如何试用他们?
for(int i=0;i<19;i++)
{
Label lb=new Label();
lb.Location=new Point(x,524);
lb.Size= new Size(48,16);
lb.BorderStyle = BorderStyle.Fixed3D;
lb.Name = "Com"+i;
lb.Text = i + "关闭";
this.Controls.Add(lb);
x=x+48;
}
下面的代码中我如何试用他们?
{ if (c is Label)
{
Label lb=c as Label;
//接下来你想干嘛? }
}
private void Form1_Load(object sender, System.EventArgs e)
{
int x = 0;
for(int i=0;i<19;i++)
{
Label lb=new Label();
lb.Location=new Point(x,524);
lb.Size= new Size(48,16);
lb.BorderStyle = BorderStyle.Fixed3D;
lb.Name = "Com"+i;
lb.Text = i + "关闭";
this.Controls.Add(lb);
x=x+48;
this.labels[i] = lb;
}
}后面想随时访问labels都可以~