"Insert" a thumbnail in an imagelist without having to reload the whole imagelist

I have an imagelist that is loaded with thumbnails. It is created on the fly using a mutilpage tiff file that is loaded in a leadtools image viewer.  The imagelist then populates a listview control for use as a thumbnail control that allows drag and drop, rearranging of pages, delteteing a page ,and adding a page by use of scanner.  I have all working, but if they make any changes in the listview, I have to clear the imagelist, then reload it completely. The multipage tiff can have as many as 3000 pages in it and it takes way to long to clear and reload everytime the user makes a change.  Is there a way to "Insert" a image into an imagelist instead of add?  I also have tried using a panel control with the following code:

Dim x As Integer
        For x = 1 To riv1.Image.PageCount
            riv1.Image.Page = x
            mypic = riv1.Image.ConvertToGdiPlusImage
            Pic = New PictureBox
            Pic.Height = 100
            Pic.Width = 100
            Pic.Top = PosLeft
            Pic.BorderStyle = BorderStyle.Fixed3D
            Pic.Left = 10
            Pic.Image = mypic
            Pic.SizeMode = PictureBoxSizeMode.StretchImage
            Txt = New TextBox
            Txt.Enabled = False
            Txt.BorderStyle = BorderStyle.FixedSingle
            Txt.Multiline = True
            Txt.Top = Postop + 100
            Txt.Left = Pic.Left
            Txt.Width = 100
            Txt.Height = 24
            Txt.TextAlign = HorizontalAlignment.Center
            Txt.Text = "Page " & x
            Postop += 150

        Next x
this works fine, but now I dont know how to actually click on the pictureboxes that are created.  It needs to Highlight like a normal thumbnail (or page) control with drag and drop capabilites. Either of these fixes will be fine (even though I would rather the fix for the imagelist as I have already got the rest of the functionality working :))

Or even a FREE thumbnail control that doesn't rely on using an imagelist.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Solutions ArchitectCommented:
ImageList control cannot be inherited, so we are tied here...
We can't manipulate the array as we'd like to.

I just coded this in a hurry, I believe it will work, but not for shure! :)))

I made it work on a seperated thread so the work can be donne on the background.
I don't think it will bring any thread problems, but you can allways use the code directly, off the Delegate scheme.

    Private Delegate Sub InsertImageDelegate( _
        ByVal imagelist As System.Windows.Forms.ImageList, _
        ByVal image As System.Drawing.Image, _
        ByVal index As Integer)

    Public Sub InsertImage( _
        ByVal imagelist As System.Windows.Forms.ImageList, _
        ByVal image As System.Drawing.Image, _
        ByVal index As Integer)
        Dim InsertImageDelegate As New InsertImageDelegate(AddressOf InsertImageWorkMethod)
        InsertImageDelegate.BeginInvoke(imagelist, image, index, AddressOf InsertImageCallBack, Nothing)
    End Sub
    Private Sub InsertImageWorkMethod( _
        ByVal imagelist As System.Windows.Forms.ImageList, _
        ByVal image As System.Drawing.Image, _
        ByVal index As Integer)

        If index >= imagelist.Images.Count Then Exit Sub

        imagelist.Images.Add(New Bitmap(10, 10)) 'Dummy image
        For i As Integer = imagelist.Images.Count - 2 To index Step -1
            imagelist.Images(i + 1) = imagelist.Images(i)

        imagelist.Images(index) = image
    End Sub
    Private Sub InsertImageCallBack(ByVal ar As IAsyncResult)
        'Use if you want to...
        'Will come here right after the InsertImageWorkMethod is finished.
    End Sub

So, you can call:
1- InsertImage Method, it will process thing on a seperated thread.
2- InsertImageWorkMethod Method, it will freeze the user until donne.

Test it and feed back to me ok?

Alex :p

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mscientist33Author Commented:
Worked Like a charm, very fast with the large multipage tiff's.  Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.