add image to imagelist if vb.net CF code

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
 
D

Daniel Moth

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
 
G

Guest

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
 

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