If I have a bunch of checkboxes and all I want to do is loop through them all and see if they are checked or not and depending on whether they are or not, set a variable. Here is the code that does it the long way:
Code:
 if (chk1.Checked)
        {
            intQ1 = 1;
        }
        else
        {
            intQ1 = 0;
        }
        if (chk2.Checked)
        {
            intQ2 = 1;
        }
        else
        {
            intQ2 = 0;
        }
        if (chk3.Checked)
        {
            intQ3 = 1;
        }
        else
        {
            intQ3 = 0;
        }
        if (chk4.Checked)
        {
            intQ4 = 1;
        }
        else
        {
            intQ4 = 0;
        }
        if (chk5.Checked)
        {
            intQ5 = 1;
        }
        else
        {
            intQ5 = 0;
        }
        if (chk6.Checked)
        {
            intQ6 = 1;
        }
        else
        {
            intQ6 = 0;
        }
        if (chk7.Checked)
        {
            intQ7 = 1;
        }
        else
        {
            intQ7 = 0;
        }
I am not sure how I would set all the variables. Each intQ is a int variable.
I know the loop is like this but the variable is what I am stuck on.

Code:
foreach (Control c in this.Controls)
{
	if (c is CheckBox) {
		MessageBox.Show(c.Name);
	}
}
Thanks for any help