//list the controls from the main form
foreach (Control c in Controls)
{
if (c is ComboBox)
{
((ComboBox)c).SelectedIndex = -1;
}
else if (c is TextBox)
{
((TextBox)c).Text = "";
}
else if (c is CheckBox)
{
((CheckBox)c).Checked = false;
}
//etc. with FIFTY different types to check against
}
if
语句中的{ }
和换行符。 - H. Pauwelyn