I have a 3 ComboBoxes in a Form, a list of objects. I need to bind the the comboboxes with 3 different members of the class from the list. (C# 3.0, .NET 3.5) I am currently doing this
Title_Combo.DataSource = ListContaining.GroupBy(item => item.Title).Where(item => !item.Key.Equals(string.Empty)).ToList();
Title_Combo.DisplayMember = "Key";
Where ListContaining is a subset of the main list of objects.Every time an item is selected in any one of those comboboxes the ListContaining is populated based on selected value from the main list of objects like and all the comboboxes are reloaded.
ListContaining = ListFiles.Where(item => item.GetType().GetProperty(name).GetValue(item, null).Equals(int.Parse(Sender.SelectedItem.ToString()))).ToList();
It loads perfectly but the next selection of the comboboxes throws a NullReference Exception.
Is this due to the fact that the List ListContaining is being rewritten or something, I can figure out.
and is there a better way to handle the 3 comboboxes from the list.
Your help is appreciated.
EDITED: I have given up debugging this. But can anyone suggest a way to bind 3 comboboxes with a single list of objects with 3 different properties. And the controls update on index change.