✅ 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?
![](https://utfs.io/f/6a921cf7-6c37-4488-bbe5-f30d729250f6-1nq2cb.png)
![](https://utfs.io/f/17e0f1c1-eb84-4bc2-b25b-ad59ed4197bd-1nq2cb.png)
7 Replies
Because you add
filteredItems
Not item
![](https://utfs.io/f/31f51985-36a3-45ff-8754-28b66ad9f662-1nq2cb.png)
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
![](https://utfs.io/f/2c8b9a79-6c57-43d2-b3dc-4fb09eb7ee6d-1nq2cb.png)
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.
![](https://utfs.io/f/1ac8969e-4464-4ec2-94a6-e679d273fa54-1nq2cb.png)
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