public SearchComponentList(Assembly assembly, ComponentTypeEnumeration type, IEnumerable <Firm> firms, IEnumerable <Lookup> lookups, GetUnitVM unitModel) { InitializeComponent(); Assembly = assembly; ComponentTypeEnumeration = type; Label.Text = $"Options for {type.GetDescription()}"; Search.Text = $"Search"; Search.Click += Search_Click; foreach (var unit in unitModel.Units) { switch (unit.UnitType) { case UnitType.CheckboxGroup: var checkboxGroupOption = new CheckboxOption(unit); OptionPanel.Controls.Add(checkboxGroupOption); break; case UnitType.RadiobuttonGroup: var radioButtonOption = new RadiobuttonOption(unit); OptionPanel.Controls.Add(radioButtonOption); break; case UnitType.Range: var rangeOption = new RangeOption(unit); OptionPanel.Controls.Add(rangeOption); break; case UnitType.Text: foreach (var option in unit.Options) { var textInput = new TextOption(unit, option); OptionPanel.Controls.Add(textInput); } break; default: break; } } var firmUnit = new Unit { Name = "Firms", Key = "firms", UnitType = UnitType.CheckboxGroup, Options = firms.Select(x => new Option { Key = "firms", Text = $"{x.Name} ({x.Country})", Value = x.Id }) }; var firmsOption = new CheckboxOption(firmUnit); OptionPanel.Controls.Add(firmsOption); foreach (var lookup in lookups) { var lookupUnit = new Unit { Name = lookup.Name, Key = lookup.Key, UnitType = UnitType.CheckboxGroup, Options = lookup.LookupValues.Select(x => new Option { Key = lookup.Key, Text = x.DisplayText, Value = x.Id }) }; var lookupOption = new CheckboxOption(lookupUnit); OptionPanel.Controls.Add(lookupOption); } }