title: Windows forms container : Panel, how to access an element at a particular index?
body: <p>I wish to check if a checkbox is checked every two element in my panel and I can't find any property or method that would allow that in the manual of Panel on MSDN site.</p>
  
  <p>I know I can check each element like that :</p>
  
  <pre><code>   foreach (CheckBox currentCheck in this.panel_Schedule.Controls)
          {
              if (currentCheck.Checked)
              {
                  nbScheduleModesChecked++;
              }
          }
  </code></pre>
  
  <p>but the problem here is that if an element is different than a checkbox is in the panel an error occure saying it can't convert the element to a checkbox.</p>
  
  <p><strong>Edit</strong> :</p>
  
  <p>To add a precision about my case, I have a panel with several CheckBox each followed by a NumericUpDown. I wish to be able to check if a checkbox is checked to :</p>
  
  <ul>
  <li>count the total of checked checkbox <strong>(this is already answered)</strong>.</li>
  <li>change the state of the NumericUpDown to hide whether the checkbox above is checked or not.</li>
  <li>change the state of a checkbox to checked or unchecked according to other checkbox which aren't in the panel.</li>
  </ul>
  
  <p>I hope this will help you to understand my problem better.</p>
  
  <p><strong>Edit 2</strong>:</p>
  
  <p>Here is an exemple of the best kind of answer i'm hoping for</p>
  
  <pre><code>   for (int i;i &lt; panel_Schedule.Controls.Count; i++)
          {
             if (panel_Schedule.__what i wish to know__[i].getType() == CheckBox)
             {
                if (panel_Schedule.__what i wish to know__[i].checked)
                {
                    //Do something like uncheck or make NumericUpDown appear
                }
             }
          }
  </code></pre>