foreach实现
/// <summary>
/// 清空界面上的按钮的内容
/// </summary>
private void ClearInputContent()
{
if (this.dateTimePicker1.Text.Length > 0)
{
this.dateTimePicker1.Text = null;
}
if (this.comboBox1.Text.Length > 0)
{
this.comboBox1.Text = null;
}
if (this.comboBox3.Text.Length > 0)
{
this.comboBox3.Text = null;
}
if (this.comboBox6.Text.Length > 0)
{
this.comboBox6.Text = null;
}
if (this.textBox1.Text.Length > 0)
{
this.textBox1.Text = null;
}
if (this.textBox2.Text.Length > 0)
{
this.textBox2.Text = null;
}
if (this.textBox3.Text.Length > 0)
{
this.textBox3.Text = null;
}
if (this.textBox4.Text.Length > 0)
{
this.textBox4.Text = null;
}
if (this.textBox5.Text.Length > 0)
{
this.textBox5.Text = null;
}
if (this.textBox6.Text.Length > 0)
{
this.textBox6.Text = null;
}
if (this.textBox7.Text.Length > 0)
{
this.textBox7.Text = null;
}
if (this.textBox8.Text.Length > 0)
{
this.textBox8.Text = null;
}
if (this.textBox9.Text.Length > 0)
{
this.textBox9.Text = null;
}
}
private void btnClear_Click(object sender, EventArgs e)
{
this.ClearInputContent();
}
用FOREACH实现