Reputation: 15
I have about nine ComboBoxes on my form and each one is filtered according to the one that came before it, so when I change the value of the first ComboBox I need to clear the rest, is there any way to loop through all of them and clear each one? I tried this:
private void Clear()
{
foreach (ComboBox cmb in Controls.OfType<ComboBox>())
cmb.Items.Clear();
}
Upvotes: 1
Views: 231
Reputation: 1101
cmb.Items.Clear(); //this removes the items
cmb.ResetText(); //this clear text
Upvotes: 1