3个回答
展开全部
给你贴个方法
/// <summary>
/// 遍历清空Form窗体上各种控件上的内容
/// </summary>
/// <param name="con">包含在控件内的控件集合</param>
public void ClearControlsData(Control.ControlCollection controls)
{
foreach (Control c in controls )
{
if (c.GetType().Name == "TextBox")
if (((TextBox)c).Visible == true)
((TextBox)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;
}
}
/// <summary>
/// 遍历清空Form窗体上各种控件上的内容
/// </summary>
/// <param name="con">包含在控件内的控件集合</param>
public void ClearControlsData(Control.ControlCollection controls)
{
foreach (Control c in controls )
{
if (c.GetType().Name == "TextBox")
if (((TextBox)c).Visible == true)
((TextBox)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;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询