I want to go through all the check boxes in form.tab and mark them as not selected. I found this was the right decision:
foreach (Control c in this.Controls)
{
CheckBox cb = c as CheckBox;
if (cb! = null & & cb.Checked)
{
cb.Checked = false;
}
}
But it does not work! And I do not understand why. I watched the debugger and cb is null. Why can this be? Where did I go wrong?
Try changing the first line from:
to
Your current code is looping though the controls directly on the form. You need to loop through the controls on the tab.