winForm窗体控件循环问题:窗体上有5个label:label1....label5用循环语句让他们显示不同的数字! 请教个问题,大家帮忙解决一下~窗体上有5个labellabel1....label5for(int i=1;i<6;i++){labeli.text=i.tostring();}这个label后面的i值怎么写?]谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以动态生成这5个label,如for (int i = 0;i < nTotals;i++){int LocationX = i*10;int LocationY = i*20;Label lb=new Label();lb.Location=new Point(LocationX*width,LocationY*height);lb.Size= new Size(158,30);lb.BorderStyle = BorderStyle.FixedSingle;//lb.AutoSize = true;lb.Name = "lbName"+i;lb.Text = ***this.panel1.Controls.Add(lb);lb.BackColor = System.Drawing.Color.Transparent;lb.DoubleClick += new System.EventHandler(this.label_DoubleClick);lb.MouseLeave += new System.EventHandler(this.label_MouseLeave);lb.MouseUp +=new MouseEventHandler(this.label_MouseUp);lb.MouseMove+=new MouseEventHandler(this.label_MouseMove);lb.Click+=new EventHandler(this.label_Click);lb.Tag = **;lb.BringToFront();lb.BackColor = System.Drawing.Color.LemonChiffon;this.panel1.Invalidate();}----------------------------------------------------------或者你需要查找form或panel里面的所有控件,当控件名字是label时赋值for(int i = this.panel1.Controls.Count - 1 ,index=1; i >= 0 ,index<6; i --){if(panel1.Controls[i].Name.ToString().Equals(label+Convert.toString(index))){panel1.Controls[i].text = "***";}} xmlreader如何返回父节点 请教高手一个问题. 怎样根据Schema来验证XML的和法性 .net中对word的操作 我需要保存登录的用户名称,ID 以及 登录时间。我该怎样处理啊? 做用户注册功能,怎么样实现第一步第二步的功能。 Response.End(),进程错误 一个我很好奇的问题!!!!!!!!!!!!!进系统前后安装程序??? 如何在没有安装过.net framework的机器上运行C#程序。初学者提问 来CSDN20天了,认识很多朋友,感觉很好,所以小散100分,有一个小建议,大家顺便看看. 关于.net wmi编程问题~ 怎样代码实现控件的拖放?请各位指教!
for (int i = 0;i < nTotals;i++)
{
int LocationX = i*10;
int LocationY = i*20;Label lb=new Label();
lb.Location=new Point(LocationX*width,LocationY*height);
lb.Size= new Size(158,30);
lb.BorderStyle = BorderStyle.FixedSingle;
//lb.AutoSize = true;
lb.Name = "lbName"+i;
lb.Text = ***
this.panel1.Controls.Add(lb);
lb.BackColor = System.Drawing.Color.Transparent;
lb.DoubleClick += new System.EventHandler(this.label_DoubleClick);
lb.MouseLeave += new System.EventHandler(this.label_MouseLeave);
lb.MouseUp +=new MouseEventHandler(this.label_MouseUp);
lb.MouseMove+=new MouseEventHandler(this.label_MouseMove);
lb.Click+=new EventHandler(this.label_Click);
lb.Tag = **;
lb.BringToFront();
lb.BackColor = System.Drawing.Color.LemonChiffon;
this.panel1.Invalidate();
}
----------------------------------------------------------
或者你需要查找form或panel里面的所有控件,当控件名字是label时赋值
for(int i = this.panel1.Controls.Count - 1 ,index=1; i >= 0 ,index<6; i --)
{
if(panel1.Controls[i].Name.ToString().Equals(label+Convert.toString(index)))
{
panel1.Controls[i].text = "***";
}
}