c# 递归遍历 清空窗体Text ComboBox 等的内容


public void findControls(Control control)
{
foreach (Control c in control.Controls)
{
string cType = c.GetType().Name;
switch (cType)
{
case "TextBox":
((TextBox)c).Text = "";
break;
case "ComboBox":
((ComboBox)c).Text = "";
break;
}

if (c.Controls.Count > 0)
{
findControls(c);
}
}
}

你可能感兴趣的:(C++,c,C#)