回复 2楼 lantian8134
public Form1()
{
InitializeComponent();
}
public void Form1_Load(object sender, EventArgs e)
{
Label [] lb = new Label[3000];
for(int i = 0; i < 3000; i++)
{
lb[i] = new Label();
lb[i].Location = new System.Drawing.Point( 80+12 * (i % 100),180+15 * (i / 100));
lb[i].Name = "btnTest";
lb[i].Size = new System.Drawing.Size(10, 12);
lb[i].Text = ".";
lb[i].BackColor = Color.White;
lb[i].Modifiers=public;
//lb[i].Font = new Font("微软雅黑", 30, FontStyle.Bold, GraphicsUnit.Pixel);
this.Controls.Add(lb[i]);
}
}
public
void timer1_Tick(object sender, EventArgs e)
{
int Vmax;
Vmax = int.Parse(textBox2.Text);
int q=0;
int m;
int v=0;
int j;
for (j = 0; j < 100; j=j + v)
{
if (lb[j].Text != ".")
{
v = int.Parse(lb[j].Text);
for (m = 1; m <= v; m++)
{
if (lb[j + m].Text == ".")
{
q = 1;
}
else
{
q = 0;
break;
}
}
if (q == 1 && v < Vmax)
{
v++;
}
else if (q == 0 && v > 0)
{
v--;
}
else v = v + 1 - 1;
}
lb[j + v].Text = v.ToString();
lb[j].Text = ".";
}
在 void timer1_Tick里面调用lb[i]等 就显示上下文不存在“lb”
怎么解决呢?谢谢