private async void ClearAll_Click(object sender, EventArgs e) { RunBackgroundWorker(); foreach (CheckBox c in Controls.OfType <CheckBox>()) { c.Checked = false; } foreach (Label l in Controls.OfType <Label>()) { if (l.Name.Contains("Result")) { l.Text = null; } } foreach (TextBox t in Controls.OfType <TextBox>()) { t.Text = null; } NotHavingSigil.Checked = true; for (int i = 0; i < Buffs.Items.Count; i++) { Buffs.SetItemCheckState(i, CheckState.Unchecked); } try { File.Delete(@"ConfigurationFiles\OwnMAttack.txt"); } catch (Exception) { MessageBox.Show("File 'OwnMAttack.txt' could not be deleted.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }