add image to imagelist if vb.net CF code

  • Thread starter Thread starter mgarner1980
  • Start date Start date
M

mgarner1980

How do I programmatically add the image file "test.bmp"
to an imagelist in vb.net Compact framwork?

I tried a similair aproach as to what I saw in the IDE generated code like
below:

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))



but couldn't get it to work
 
Add the files to your project as embedded resources (look at the properties
window for each file).

From code, look up the method GetManifestResourceStream, i.e.:
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(...)

Cheers
Daniel
 
If you do not know which images you want to "deploy" with your app, you could
use this code to load the images from disk into an imagelist;

dirInfo = New System.IO.DirectoryInfo("\Program Files\<Your app
name>")
files = dirInfo.GetFiles("*.jpg")
If Not (files Is Nothing) Then
For Each file In files
tBitmap = New System.Drawing.Bitmap(file.FullName)
imlImages.Images.Add(tBitmap)
Next
End If

Cheers
Peter
 
Back
Top