I'd like to fill a multi-column System.Windows.Forms.ListView with the items I've stored in a separate System.Collections.Generics.List<CustomClass>
. I would like to avoid to store the data twice, once in the List<CustomClass>
and once as a string in ListViewItem. Is there a way to make ListViewItem use some callback function to obtain the text to put in its columns from the Tag property, instead of using its Text property?
Update: I've tried the OnDrawSubItem solution and it worked, but I experienced strange window invalidation problems (the ListView was always redrawn correctly, but the other windows in the dialog weren't). However, I found what I was looking for: ListView in "virtual mode". It allows to fill the ListView with data from another source, which is automatically updated when the source is modified.