mardi 27 décembre 2016

How do I use if statements with checkboxes without clutter

I have this application with 13 checkboxes.
And i want to do if statements to check if a textbox is checked but its going to get really cluttered after checking 4 of them for example

if (checkBox1.IsChecked == true)
    {
          DoSomething();          
    }

else if (checkBox1.IsChecked == true && checkBox2.isChecked = false)
    {
          DoSomething();          
    }

else if (checkBox1.IsChecked == false && checkBox2.isChecked = true)
    {
          DoSomething();          
    }

else if (checkBox1.IsChecked == false && checkBox3.isChecked = true)
    {
          DoSomething();          
    }

else if (checkBox1.IsChecked == false && checkBox3.isChecked = false)
    {
          DoSomething();          
    }


else if (checkBox1.IsChecked == true && checkBox3.isChecked = false)
    {
          DoSomething();          
    }

else if (checkBox1.IsChecked == true && checkBox3.isChecked = true)
    {
          DoSomething();          
    }

I bet you can see the pattern already.. I need to check every possible solution for 13 checkboxes, is there a way to do this more efficiently?




Aucun commentaire:

Enregistrer un commentaire