470,643 Members | 1,348 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,643 developers. It's quick & easy.

imagelist and bitmaps

Sam
Hi,
I've added two bitmaps to my project. Now I would like to create an
imagelist (in the code) and add those two images to it (so no path,
just the name). And I want those images to be compiled in the .dll.
This is a user control, so this why I want them to be embedded within
the dll.

Thx

Nov 21 '05 #1
9 1255

You don't need to add them to your project. You can either add an imagelist
control to your form and add the images in the property editor of the
control; doing this will make them resources. Or you can right click on the
bmp file and compile it as an embedded resource - then get them at run-time.
I would recommend the former as it's a bit easier than flapping around with
embedded resources manually.
"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi,
I've added two bitmaps to my project. Now I would like to create an
imagelist (in the code) and add those two images to it (so no path,
just the name). And I want those images to be compiled in the .dll.
This is a user control, so this why I want them to be embedded within
the dll.

Thx

Nov 21 '05 #2
Set the bitmaps build action to embedded resource and try this code to get
the image and load it in the imagelist:

Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Dim img As New Bitmap(p.GetManifestResourceStream(Me.GetType(),
"envelop.jpg"))
ImageList1.Images.Add(img)

hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Sam" <sa**************@voila.fr> schreef in bericht
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi,
I've added two bitmaps to my project. Now I would like to create an
imagelist (in the code) and add those two images to it (so no path,
just the name). And I want those images to be compiled in the .dll.
This is a user control, so this why I want them to be embedded within
the dll.

Thx

Nov 21 '05 #3
Sam
Thx Peter, that seems to work!

Nov 21 '05 #4
Hi, I know it does, but I would also go for the first suggestion Robin made,
becauses it's more clear then getting things from the assembly

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Sam" <sa**************@voila.fr> schreef in bericht
news:11**********************@g47g2000cwa.googlegr oups.com...
Thx Peter, that seems to work!

Nov 21 '05 #5
Sam
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx

Nov 21 '05 #6
Sam
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx

Nov 21 '05 #7
You should be able to drag/drop an image list onto a user control - unless -
ahh, I see. Was there a specific reason you derived from panel?

"Sam" <sa**************@voila.fr> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx

Nov 21 '05 #8
Sam
it's not even a user control, it's more like an inherited control. I've
just created my own personified docking panel. So in design mode there
is nothing to see.

Nov 21 '05 #9
Just out of interest - I've learnt to gather all my images in one place and
dynamically load them into a global singleton - similar to the way Peter
suggests. The reason for this is because often many components share
images/icons and it's helps keep .exe size down if you share instances
(provided they don't get edited of course), rather than adding them at each
location. Same for toolbar icons, which often are used in many
components/places.
"Sam" <sa**************@voila.fr> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx

Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bruno Zarokian | last post: by
1 post views Thread by JaguarX | last post: by
2 posts views Thread by A. Solomon | last post: by
11 posts views Thread by Juan Romero | last post: by
16 posts views Thread by Roger | last post: by
2 posts views Thread by sonu | last post: by
reply views Thread by Homer J Simpson | last post: by
2 posts views Thread by Michael Maes | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.