✅ Returning (Collection) from LINQ Query
I query from a list called invItems based off a filter, but after returning the results from the query using ToList(), the items are shown as (Collection) in my combo box. Why is it doing this?
7 Replies
Because you add
filteredItems
Not item
now it returns this. the filter does work, as it will show less items depending on the filter. but i want it to show the items name / description / cost
You can either add just those strings to the list, add a
.ToString()
overload to your class, or maybe use some binding stuff on the UI side
Not sure about the last option since I never worked with WinformsHow do you want it to look? If you want each item to read name / description / cost, then when you do your foreach to add the list items, instead of adding the invitem object, put those three properties together using string interpolation.
I would use DisplayMember
this worked, thank you so much... im still new to C and sometimes struggle to think like the computer does. thank you
and thank you everyone for the help