0
votes

I have a problem with my combobox. I've set DataSource which contains a list of objects, DisplayMember and also ValueMember but there are times when the combobox displays the namespace where the object class is placed. For example: Project.Interface.Object

cmbAuto.DataSource = Collections.ProfileList.FindAll(t => t.IsAuto);
cmbAuto.DisplayMember = "Name";
cmbAuto.ValueMember = "ID";
cmbAuto.SelectedIndex = -1; 
2
Here is the code: cmbAuto.DataSource = Collections.ProfileList.FindAll(t => t.IsAuto); cmbAuto.DisplayMember = "Name"; cmbAuto.ValueMember = "ID"; cmbAuto.SelectedIndex = -1;Stefania Mereut

2 Answers

0
votes

I suggets you to use Where operator

cmbAuto.DataSource = Collections.ProfileList.Where(t => t.IsAuto);

Nota : FindAll() is a function on the List type, it's not a LINQ extension method like Where.

0
votes

I've solved the problem by overriding ToString method of the object.