1

I'm developing an application that use a combobox in wpf. I'm using a class that contain two values ID and Name, I'm bulding a list with this class to be the ItemsSource of the combobox, as follow:

Example.cs

foreach (XmlNode OEM in OEMs) { string OEMname = OEM.Attributes["OEMname"].InnerText; int ID = Int32.Parse(OEM.Attributes["ID"].InnerText); OEM oem = new OEM { OEMname = OEMname, ID = ID}; oems.Add(oem); } cbxSelOEM.ItemsSource = oems; 

My problem is the value shown in the combobox, instead of show the OEMname value they show other name, I believe that is the object name in the list. How can I solve this problem?

1
  • 1
    Try cbxSelOEM.DisplayName = "OEMname"; Commented Feb 22, 2017 at 16:53

1 Answer 1

2

Typically the ToString() of objects is shown at the ComboBox. To show the OEMname simply set the DisplayMemberPath like

cbxSelOEM.DisplayMemberPath = "OEMname"; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.