title: How many CheckBoxes are checked in the GroupBox?
body: <p>I'm making a program that has to count how many <code>CheckBox</code> controls are checked, only in a <code>GroupBox</code>.</p>
  
  <p>I've tried a lot of different ways but I can't get it work.</p>
  
  <p>How can this be made?</p>
  
  <pre><code>// This is one of the many things I tried...        
  public CheckBox rNum;
  //This method is used on FormLoad.
  public void CreateBoxes()
  {
      for (int i = 0; i &lt; 36; i++)
      {
          rNum = new CheckBox();
          rNum.Text = i.ToString();
  
          //CheckBoxes added to flowLayoutPanel.
          flw.Controls.Add(rNum);
      }   
  }
  
  public int count;          
  //This method is used on Button Click
  public void CountIt()
  {
      foreach (CheckBox box in groupBox.Controls.OfType&lt;CheckBox&gt;())
      {
          if (box.Checked)
          {
              count++;
          }
      }    
      MessageBox.Show(count.ToString());
  }
  </code></pre>