mercredi 30 octobre 2019

Checkbox in specific label

It's really easy but complicated to explain:

I have checkboxes, 10 in total but there is a limit, we can only check 5 of the 10. Let's imagine that we tick a box in two and press validate. I would get a bool array that looks like this:

true, false, true, false, false, true, false, false, false, false

Knowing that each box has a value: first box = Animal second box = Capital....

Now I come to my question:

I have 5 labels and I would like it to be 5 labels corresponding to the value of the checkbox. So how to make it 5 labels is all a different value that corresponds to the checkbox.

Here is my code:

    bool[] categorie = new bool[10] { 
        false, true, false ,true ,false ,
        true ,false ,true, false, true };

    string[] categorieName = new string[10] {
       "Animaux", "Capitale", "Fruit", "Légume", "Pays", 
       "Prénom fille", "Prénom garçon", "Métier", "Moyen de transport", "Sport" };

So I have already completed the bool array but it completes itself by itself according to the checkboxes

And the second is value.

so I would like my labels to be:

Capitale, Légume, pays, prénom garcon, moyen de transport

Thank you for having and please explain a solution (loop for ? if? I don't know)




Aucun commentaire:

Enregistrer un commentaire