I had the same problem, but I worked with generics. I used the combo box binding context to get rid of this. (Very useful when you do not know the size of the binding list - in your case, these are 5 elements)
In the code below, DisplayBindItem is just a class with a key and value.
List<DisplayBindItem> cust = (from x in _db.m01_customers where x.m01_customer_type == CustomerType.Member.GetHashCode() select new DisplayBindItem { Key = x.m01_id.ToString(), Value = x.m01_customer_name }).ToList(); cmbApprover1.BindingContext = new BindingContext(); cmbApprover1.DataSource = cust; cmbApprover1.DisplayMember = "Value"; cmbApprover1.ValueMember = "Key";
Class for reference.
public class DisplayBindItem { private string key = string.Empty; public string Key { get { return key; } set { key = value; } } private string value = string.Empty; public string Value { get { return this.value; } set { this.value = value; } } public DisplayBindItem(string k, string val) { this.key = k; this.value = val; } public DisplayBindItem() { } }
Please mark as an answer if this solves your problem.
source share