[Closed] Adding images to listview incrementally: how to?
Hi,
I’m using a listview to display thumbnails of assets in our library. It works fine, I create an imagelist, create images, add the images to the list and finally add the list to the listview. My problem is the following: when there are many images (eg 100) I have to wait until the entire imagelist has been created. Then they pop up in the listview. this may take a while depending on the amount of images. I’d like to see my images appear in the listview one by one, as they’re created. I think this i how the windows explorer displays its images for instance. Is there a way to do this in maxscript and dotnet? I’ve already worked with the multithreading system described by Lonerobot, but that also pops in all images at once.
Klaas
I’ve done something similar though I had the list view in virtual mode and added to the image list as I created each list view item. That was hundreds of images and it updates pretty damn quick. It also used caching to reduce the amount of list item creation. The image list gets re-created when it caches so that there are only the exact amount of images in the list that it actually needs.
Cheers,
Paul
Yeah, I also thought about the virtual thing. How did you add each item to the list one by one? When i do that without the virtual mode, i can add the items to the imagelist one by one but the images are shown in one go anyway. Could you maybe show an example?
Klaas
I’m at home and my pc is dead, using my phone I’ll give you an example if I get my pc working or on Monday when I’m back at work.
It involves using a cache. When it decides to rebuild the cache, you clear the image list so that it only rebuilds with the images it needs. I created a function that gets called when it requests a new list view item. The function also adds the required image to the image list. The function is called both when it retrieves and when it caches. Search on msdn for listview virtualmode for a good example if you can’t wait. Post any questions and I’ll reply
I’m working with the virtualmode right now. Adding items works fine. Now I’ve got the following problem: I’m unable to get the selected items!
In virtualmode the items or selecteditems collections are unavaliable, only the selectedindices collection works. In my script, when a user clicks an item in the listview, I need to get the tag of the item. do you know how to get that? I don’t see an efficient way to get the item.tag.
I’m also interested in your example.
Klaas
I’m unable to give you a proper example right now, way too busy, but you can get all you need via the selectedIndices. You must have an array of all the items in one form or another because you couldn’t create a new listview item without it when it attempts to retrieve a new item. The selectedIndices will match that array though you must add 1 to the index if it’s a standard max array.
Paul