Checking checkboxes
<p>I am looking for a way to check if the user has checked more than one box. </p>

<pre><code>if (checkBox1.Checked == true)
            if (checkBox2.Checked == true)
                MessageBox.Show("Please select one car type");
            else if (checkBox3.Checked == true)
                    MessageBox.Show("Please select one car type");
</code></pre>

<p>The problem with the way I have it is it only shows the message box if the user checks the first checkbox then if they select the second one the messagebox.show comes up. But if the user selects the second and third the message doesnt show up.</p>

<p>I do understand I can do it the way I have below but I think there is a better way with less code. Because by doing it the way I have below the message pops up twice if checkbox 2 is checked.</p>

<pre><code>if (checkBox1.Checked == true)
            if (checkBox2.Checked == true)
                MessageBox.Show("Please select one car type");
            else if (checkBox3.Checked == true)
                    MessageBox.Show("Please select one car type");
        if (checkBox2.Checked == true)
            if (checkBox1.Checked == true)
                MessageBox.Show("Please select one car type");
            else if (checkBox3.Checked == true)
                MessageBox.Show("Please select one car type");   
</code></pre>
