StrataFrame Forum

How to re-use an imagelist control?

http://forum.strataframe.net/Topic16930.aspx

By Edhy Rijo - 6/9/2008

Hi, it is possible to have a global image list I could re-use in different forms?



For some task I am saving the images in the project's Resource, but some controls like the ListView requires an ImageList control and I don't want to have to enter all images used by several forms in several ImageList controls.
By Trent L. Taylor - 6/10/2008

Sure, just create a resource file or use the resources in the project itself.  If you just right-click and add a new item, then select Resource File.  Then once in your project, add a new item to the resource file and select the image(s) that you want.  Also, be sure to set the imported images to Embedded instead of Content.  At this point, you can choose a local resource from anyplace within your project and select from that resource file.
By Greg McGuffey - 6/10/2008

Is there any way to do this across a solution? I.e. have a resource file that is accessible from all the projects in a solution?
By Edhy Rijo - 6/10/2008

Thanks Trent,

I will try the resource file, but how to use those images in the resource file in the ListView, since this controls requires an ImageList controls to refer to?

All I want to do is not having to add imagelist controls all over the app and use a single ImageList or Resource file for all my images for this project.  I hope this could be done since I hate to keep doing the same thing over and over and over Wink

By Trent L. Taylor - 6/10/2008

Greg:

Is there any way to do this across a solution? I.e. have a resource file that is accessible from all the projects in a solution?

Not easily.  Really it is best to setup this up by project.

I will try the resource file, but how to use those images in the resource file in the ListView, since this controls requires an ImageList controls to refer to?

We never use the designer for the ImageList control anyway as after a few compiles, the quality of the image degrades.  So when we use an ImageLIst control, we add a method that we call in the constructor or OnLoad that populates the image list from resource images...this way the images will always remain crisp and clean.

By Greg McGuffey - 6/10/2008

Thanks. That's what I've been doing, but Edhy's post got me thinking! BigGrin
By Edhy Rijo - 6/10/2008

Trent L. Taylor (06/10/2008)
So when we use an ImageLIst control, we add a method that we call in the constructor or OnLoad that populates the image list from resource images...this way the images will always remain crisp and clean.

Well that would be what I am looking for because in that case all my images will be in the common Resource File and then the image list would be programatically be filled with the images needed from the resource file. Could you share some code on how to import the images from the resource file?

Also that could be a new SF ImageList control in future updates...Hehe

By Trent L. Taylor - 6/10/2008

Also that could be a new SF ImageList control in future updates

If it were that simple we would have already done it.  This will require that we replumb the ListView, etc.  At present this is still standard .NET logic.  Trust me, this has already crossed our minds hundreds, it not thousands of times!