private void OperateControls(Control control) { foreach (Control c in control.Controls) { if (c is Panel) { OperateControls(c); } if (c is GroupBox) { OperateControls(c); } if (c is TextBox) { // 它是 TextBox, 要干什么随便你 } } }
private void ClearValue(Control ctrl) { foreach(Control c in ctrl.Controls) { if(c is TextBox) { (c as TextBox).Clear(); // 清空 } else if(c.HasChildren) { ClearValue(c); // 递归 } } }
var obj=document.getElementByTagName("input");
for(var i=0;i<obj.length;i++)
{
if(obj[i].type.toLower()="text")
{
obj[i].value="";
}
}
{
foreach (Control c in cs)
{
if(c.GetType() ==typeof(textbox))
c.text="";
if(c.Controls .Count >0)
setControlSize(c.Controls);
}
}
{
foreach (Control c in control.Controls)
{
if (c is Panel)
{
OperateControls(c);
}
if (c is GroupBox)
{
OperateControls(c);
}
if (c is TextBox)
{
// 它是 TextBox, 要干什么随便你
}
}
}
{
foreach(Control c in ctrl.Controls)
{
if(c is TextBox)
{
(c as TextBox).Clear(); // 清空
}
else if(c.HasChildren)
{
ClearValue(c); // 递归
}
}
}