Populating an ImageList

T

Terry Olsen

I have the following code:

Private Sub LoadImageList()
Dim il As New ImageList
Dim di As New DirectoryInfo(ImgDir)
For Each fi As FileInfo In di.GetFiles
Dim bmp As Image = DevIL.DevIL.LoadBitmap(fi.FullName)
PictureBox1.Image = bmp
il.Images.Add(fi.FullName, PictureBox1.Image)
Next
ImgList.LargeImageList = 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top