C#我在后台这里加的lable,怎么统计不出来个数

[复制链接]
查看11 | 回复1 | 2008-5-18 16:40:20 | 显示全部楼层 |阅读模式
for (int i = 0; i < this.CheckBoxList1.Items.Count;i++ )
{
if (this.CheckBoxList1.Items.Selected)
{
Label lb = new Label();
lb.Text = i.ToString();
lb.ID = i.ToString();
lb.Visible = true;
lb.Enabled = true;
lb.EnableTheming = true;
lb.EnableViewState = true;
this.Panel1.Controls.Add(lb);
}
}
this.TextBox1.Text = this.Panel1.Controls.Count.ToString();兄弟!! 我试过了 可我不管怎么试他阿斗能统计出来啊!~~~就没有出不来的时候真服了~~~
回复

使用道具 举报

千问 | 2008-5-18 16:40:20 | 显示全部楼层
这错误就出在给 textBox1 赋值,因为textBox1 只接受字符串格式的,所以你给他赋值的时候应该:this.TextBox1.Text = this.Panel1.Controls.Count.ToString(); Panel1.Controls.Count这 只是求出他的总数后面加个ToString()就可以了.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行