I have a file downloader, so there is a list view with such columns: a file name, a speed, a file size, a downloaded size, left/elapsed time, percent done (a progress bar) -> I need to draw icons, a text, a background, a progress bar etc. What is an efficient method to store all data to draw it in a list view?
For example I draw a text “error”, then a background must be red. I can check an error and draw with something like this if SameText(Item.SubItems[5], 'error') then, but I don’t know if it’s fast to draw all items with this method, to store all data in a list view?
ListView is a visual representation of linear list of data items. ListView itself should not be used as a data container.
Your right approach is to have a separate TList with records or objects, each corresponding to one downloaded item. When you add an “item” to ListView, you can specify associated user data. The user data in your case is a reference to the record or an object.
When you need to draw a listview item, you take the data from the associated record or object.
Actually, if you have a list of downloaded items, then you already have everything you need to do, and the missing part in the puzzle is that listview item can hold a reference to user data.