/// 清除容器里面某些控件的值 /// </summary> /// <param name="parContainer">容器类控件</param> public void ClearCntrValue(Control parContainer) { for (int index = 0; index < parContainer.Controls.Count; index++) { // 如果是容器类控件,递归调用自己 if (parContainer.Controls[index].HasChildren) { ClearCntrValue(parContainer.Controls[index]); } else { switch(parContainer.Controls[index].GetType().Name) { case "TextBox": parContainer.Controls[index].Text = ""; break; case "RadioButton": ((RadioButton)(parContainer.Controls[index])).Checked = false; break; case "CheckBox": ((CheckBox)(parContainer.Controls[index])).Checked = false; break; case "ComboBox": ((ComboBox)(parContainer.Controls[index])).Text = ""; break; } } } }
标签:case,控件,parContainer,index,C#,Controls,break,清空 From: https://www.cnblogs.com/kingkie/p/16932533.html