怎么遍历多个DropDownList 我的页面里有44个DropDownList怎么遍历? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 foreach (Control con in this.Page.Controls){ } 放這么多DropDownList速度會不會慢? foreach (Control con in this.Page.Controls){ if(con is DropDownList ) { }} 假如你的控件在panel里foreach (Control con in Panel1.Controls) { if(con is DropDownList ) { } } 不过那你的页面运行速度就太惨了。 private void test(Control c) { foreach (Control childControl in c.Controls) { if (childControl is DropDownList ) { } else test(childControl); } }递归实现 是页面的话 要这样!foreach (Control myc in form1.Controls) { if (myc is TextBox) { TextBox tb = (TextBox)myc; tb.Text = string.Empty; 要做什么在这里做 就可以了。 } } winform打印程序,可以调整字符间距吗?急~ 请教List.add 与 Find 语法问题! asp.net页面取数据库值的问题,急急急,在线等答案。 VS2008的问题,请指点。 asp.net gridview 日期时间中,对日期的查询问题,在线等 求教一个简单的问题......XDJM门帮忙啊。感谢中! 请教几个关于类的基础问题. 关于项目文件目录的问题? 怎么在.net中加入ocx 在真實的項目中,委托是如何被使用的,能給我描述一個場景么? 急~请尽快帮忙解决
{
}
foreach (Control con in this.Page.Controls)
{
if(con is DropDownList )
{
}
}
foreach (Control con in Panel1.Controls)
{
if(con is DropDownList )
{
}
}
不过那你的页面运行速度就太惨了。
{
foreach (Control childControl in c.Controls)
{
if (childControl is DropDownList )
{
}
else
test(childControl);
}
}
递归实现
foreach (Control myc in form1.Controls)
{
if (myc is TextBox)
{
TextBox tb = (TextBox)myc;
tb.Text = string.Empty; 要做什么在这里做 就可以了。
}
}