title: How to uncheck all checkboxes in all my panels
body: <p>I am trying to uncheck all the checkboxes in all the panels I have.
  This is different from other questions because it is for every panel that has a checkbox.
  The code I have right now unchecks all the checkboxes in the form but not in all the panels.</p>
  
  <pre><code>foreach (CheckBox control in this.Controls.OfType&lt;CheckBox&gt;())
  {
      control.Checked = false;
  }
  </code></pre>
  
  <p>I have a bunch of panels and checkboxes in them and there has to be a simple way to uncheck them all.</p>
  
  <p>this does it to every checkbox in my form instead of only panels
  my code:</p>
  
  <pre><code>private void button16_Click(object sender, EventArgs e)
  {
      clearStuff((Control.ControlCollection)this.Controls);
  }
  private void clearStuff(Control.ControlCollection obj)
  {
      foreach (Control control in obj)
      {
          if (control.HasChildren)
              clearStuff(control.Controls);
          else
              if (control is CheckBox)
              {
                  CheckBox check_box = (CheckBox)control;
                  check_box.Checked = false;
             }
      }
  }
  </code></pre>
  
  <p>this works but it could be refactored</p>
  
  <pre><code>foreach (Panel control2 in this.Controls.OfType&lt;Panel&gt;())
  {
      foreach (CheckBox control1 in control2.Controls.OfType&lt;CheckBox&gt;())
      {
          control1.Checked = false;
      }
  }
  </code></pre>