Click to See Complete Forum and Search --> : ImageList


PaulJayKnight
June 13th, 2009, 07:22 PM
Is there a way to create a user-defined ImageList? I would like the user to be able to assign images to ImageList that would be stored for use in future sessions.

dglienna
June 13th, 2009, 10:56 PM
Many different ways. Where are the images coming from?

You could store them in a resource file, a database, or even an xml file

PaulJayKnight
June 14th, 2009, 02:35 AM
These Images are coming from the client's own Image files.

DataMiser
June 14th, 2009, 10:35 AM
You may find this code helpful.

This piece is behind a button in one of my projects, there is much more there but this is the part that should interest you.


files = Directory.GetFiles(IMAGE_DIRECTORY, "*.jpg")
Me.Cursor = Cursors.WaitCursor
ImageList_Load()


The sub routine called by the above

Private Sub ImageList_Load()
Dim pname As String
Dim myImage As Image
Dim PG As New frmProgress
PG.lblStatus.Text = "Creating Thumbnails"
PG.ProgressBar1.Value = 0
PG.ProgressBar1.Maximum = files.Length
PG.Show()
PG.Refresh()
ImageList1.Images.Clear()
'Set the ColorDepth and ImageSize properties of imageList1.
ImageList1.ColorDepth = ColorDepth.Depth32Bit
ImageList1.ImageSize = New System.Drawing.Size(100, 75)
max_length = files.Length - 1
'Add images to imageList1.
For i = 0 To max_length
PG.ProgressBar1.Value = PG.ProgressBar1.Value + 1
pname = Path.GetFullPath(files(i))
myImage = Image.FromFile(pname)
ImageList1.Images.Add(myImage)
myImage = Nothing
Next
pname = Nothing
PG.Close()
PG.Dispose()
End Sub

Basically this adds a thumbnail image of all jpg files in the given folder to an image list. In the case of the project where this code is from the user is pointing it to a digital camera.