|
Windows Form ListBox -- Joe Enos --
Is there any way to have a value behind the text on a Windows Form ListBox? It's easy in ASP.NET - you get a text and a value object for each item. However, it looks like the Windows ListBox is simply a collection of strings - the object collection it contains seems to be worthless unless those objects are strings. If you can place non-string objects on a ListBox, how can you display one particular property of that object? Thanks for the help. Joe Enos |
|
-- Cerebrus --
The DisplayMember and the ValueMember properties are what you want. Check 'em out. |
|
-- Joe Enos --
Thanks. I'll check into that. But in the meantime, I was able to figure out that a class's "ToString" method is what actually displays in the ListBox. So after I added an override ToString() method to my class, I was able to keep the collection of objects in my ListBox, and still have it display exactly as I wanted to. Thanks Joe Enos |