Recommended Posts

Hi, for my game in XNA, I decided to use a Windows Form as the inventory interface. On the Form, I added a ListView item. So far it is working well, but now that I want to add quantities of items, it is not going to work. How can I set it so that the list of items in the ListView are my own custom objects (I have an Item class). If I could find a way to implement this, I think it would be much easier. All help would be appreciated

0

Share this post

Link to post

Share on other sites

There is a "Tag" member in the ListViewItem class, which is used to associate the listview item with user data. That's probably what you need. Set the Tag property to the GameItem object. Of course, with Tag being of type "object", you'll need to cast back to GameItem when retrieving the object from the listview item. A small example: