1

I have set up an [Flag] Enum that holds safety details regarding chemicals (Corrosive, Toxic etc). I have bound the names from the Enum to a ComboBoxList with no issues but what I would like it for the CheckBoxList to check the correct names based upon the values currently stored in the Enum.

I have thought about looping through each item in the CheckBoxList and then seeing if that item is flagged in the Enum but have had no luck.

Thanks

Edit So the CheckListBox is populated from the Enum;

foreach(Coshh c in Enum.GetValues(typeof(Coshh)))
        {
            if (c.ToString() != "None")
            {
                clbCoshh.Items.Add(c, false);
            }
        }

And I would like this to be updated based upon the Stock Object selected from the ComboBox. The Enum is stored at _stock.Value.Hazards (Hazards is the Flag Enum within the Stock object)

private void cmdAdd_Click(object sender, EventArgs e)
    {
        WorkingTemp.Add(new WorkingItem(ID++,_stock.Key,_stock.Value.ChemicalName,
            Convert.ToDouble(txtAmount.Text),(_stock.Value.ChemicalUnitCost*Convert.ToDouble(txtAmount.Text))));
        RefreshWorking();
    }
  • 2
    Would you mind sharing your code with us? – L. Guthardt Dec 20 '17 at 10:35
  • 1
    Possible duplicate of [WPF ComboBox/ListBox with MultiSelect based on Enum with Flags](https://stackoverflow.com/questions/1547124/wpf-combobox-listbox-with-multiselect-based-on-enum-with-flags) – Mikolaytis Dec 20 '17 at 10:43

0 Answers0