mercredi 4 octobre 2017

C# Switch case on checkbox

I have following code which handles the CheckedChanged-event on 12 checkboxes.

 private void cbJournal_CheckedChanged(object sender, RoutedEventArgs e)
    {
        CheckBox chk = (CheckBox)sender;

        if (chk.IsChecked == true)
        {

            switch (chk.Name)
            {
                case "cbErbbstg":
                    {
                        month = Months[idxMonth];
                        LinkToRSS.Add(link + month);
                        RSSname.Add(name);
                        Picture.Add(picture);
                        ID.Add(100);

                    }
                    break;

                case "cbGstb":
                    {
                        month = Months[idxMonth];
                        LinkToRSS.Add(link + month);
                        RSSname.Add(name);
                        Picture.Add(picture);
                        ID.Add(200);
                    }
                    break;
          }
   }

Now I want to implement a checkbox which, if checked, checks every other checkbox too, and adds all elements to the lists.

That is, I want to iterate through all cases somehow, so every list can be populated with values.

Any suggestions?




Aucun commentaire:

Enregistrer un commentaire