/// <summary>
/// 遍曆清除指定的控件
/// 塗聚文 2011-10-18
/// 締友計算機信息技術有限公司
/// </summary>
/// <param name="con"></param>
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;
}
}
//調用方法
Control.ControlCollection coll = this.Controls;
formOperatin.ClearControl(coll);
Csharp windowform controls clear
最新推荐文章于 2024-06-21 08:34:23 发布