C# – Entity Framework – Bind Combobox to Normalised Table Field


I am currently trying to bind an entity to a form however I want to have DataConfidenceLevel (see below) bound to a combobox with ConfidenceDescription as the display member. What is the correct way to populate the combobox?

(I am currently using WPF but a Winforms answer is acceptable)


Entity Designer http://img19.imageshack.us/img19/374/entity.png

Best Solution

You want to bind a collection to a control and have a releated entity - namely navigation property DataConfidenceLevel of type DataConfidenceLevel - as the display member?

That is usually achieved really simple by overriding ToString(),

public partial class DataConfidenceLevel
   public override String ToString()
      return this.ConfidenceDescription;

and than setting DisplayMember to the DataConfidenceLevel property of the entity you want to bind.