////// 遍曆清除指定的控件 /// 塗聚文 2011-10-18 /// 締友計算機信息技術有限公司 /// /// public void ClearControl(Control.ControlCollection con) { foreach (Control C in con) { if (C.GetType().Name == "TextBox") if (((TextBox)C).Visible == true) ((TextBox)C).Clear(); if (C.GetType().Name == "MaskedTextBox") if (((MaskedTextBox)C).Visible == true) ((MaskedTextBox)C).Clear(); if (C.GetType().Name == "ComboBox") if (((ComboBox)C).Visible == true) ((ComboBox)C).Text = ""; if (C.GetType().Name == "PictureBox") if (((PictureBox)C).Visible == true) ((PictureBox)C).Image = null; } } //在winForm調用方法 Control.ControlCollection coll = this.Controls; formOperatin.ClearControl(coll);