日期:2014-05-17 浏览次数:21289 次
foreach (Control c in Controls)
{
if (c is TextBox)
{
c.Text =string.Empty;
}
}
------解决方案--------------------
foreach (Control cl in this.Controls)
{
if (cl is ComboBox)
{
ComboBox cb = cl as ComboBox;
cb.Items.Clear();//清除绑定项
}
else if (cl is TextBox)
{
TextBox tb = cl as TextBox;
tb.Text = string.Empty;//清除所有TextBox
}
else
{
}
}
------解决方案--------------------
foreach (Control cl in this.Controls)
{
if (cl is ComboBox)
{
ComboBox cb = cl as ComboBox;
cb.DataSource = null;
cb.Items.Clear();//清除绑定项
}
else if (cl is TextBox)
{
TextBox tb = cl as TextBox;
tb.Text = string.Empty;//清除所有TextBox
}
else
{
}
}
------解决方案--------------------