我是初学者,请教个问题,我用以下代码给form添加
label控件,为什么总是只出现一个label呢?
for (int i = 0; i < jiyiliang; i++)
{
//文本形式随机化
Random a = new Random();
if (a.Next(0, 100) % 2 == 0)
lab0.Text = Convert.ToString(test0[i]);//如果判断是偶数则直接将数组中的
else
{
Random c = new Random();
int b = c.Next(0, 20);
lab0.Text = Convert.ToString(test0[i] - b) + "+" + Convert.ToString(b);
}
//高宽,位置,颜色
lab0.Size = new Size(100,30);
lab0.Location = new Point(left * i,i % 2==0?top:2*top);
lab0.Font = new Font("宋体", 20);
lab0.BackColor = Color.AliceBlue;
lab[i]= lab0;
this.Controls.Add(lab[i]);
}