I am generating dynamically Checkbox-buttons on a panel according to my SQL data. I created a button to "refresh" my buttons, I mean I delete / update buttons. My problem is I cannot delete the old buttons. After a created the buttons I am trying to delete a specific one:
foreach (CheckBox item in panel.Controls.OfType<CheckBox>())
{
panel.Controls.Remove(item);
}
There are only a few deleted. Any suggestion?