Populating an ImageList

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    #1

    Populating an ImageList

    I have the following code:

    Private Sub LoadImageList()
    Dim il As New ImageList
    Dim di As New DirectoryInfo(I mgDir)
    For Each fi As FileInfo In di.GetFiles
    Dim bmp As Image = DevIL.DevIL.Loa dBitmap(fi.Full Name)
    PictureBox1.Ima ge = bmp
    il.Images.Add(f i.FullName, PictureBox1.Ima ge)
    Next
    ImgList.LargeIm ageList = il
    End Sub

    Even though the PictureBox can display the image, I get the following error
    when trying to add the image to the ImageList.

    "Image added to an ImageList must either derive from Image or be an Icon."

    How can I fix this?

    Thanks.


  • Newbie Coder

    #2
    Re: Populating an ImageList

    Terry,

    Although I said I wouldn't help you again I found this article a few weeks
    back. Its not 100% what you want but you can get the idea:



    --
    Newbie Coder
    (It's just a name)




    "Terry Olsen" <tolsen64@hotma il.comwrote in message
    news:%23mJINxWl HHA.2552@TK2MSF TNGP06.phx.gbl. ..
    I have the following code:
    >
    Private Sub LoadImageList()
    Dim il As New ImageList
    Dim di As New DirectoryInfo(I mgDir)
    For Each fi As FileInfo In di.GetFiles
    Dim bmp As Image = DevIL.DevIL.Loa dBitmap(fi.Full Name)
    PictureBox1.Ima ge = bmp
    il.Images.Add(f i.FullName, PictureBox1.Ima ge)
    Next
    ImgList.LargeIm ageList = il
    End Sub
    >
    Even though the PictureBox can display the image, I get the following
    error
    when trying to add the image to the ImageList.
    >
    "Image added to an ImageList must either derive from Image or be an Icon."
    >
    How can I fix this?
    >
    Thanks.
    >
    >

    Comment

    Working...