Images in user controls and Memory Use

The Red Duke

Newcomer
Joined
Aug 31, 2003
Messages
2
Location
Bath, UK
Hi all,

Normally I use VB just trying to write something in C# at the moment (not that this is the problem)

I was creating a user control for a 'log entry' (basically a panel with labels in and a picture box) this then displays a summery of information on a 'log' and the picture box shows an image that helps denote the status.

My question is if I was to include all the 6 icons I have made (that cover all my status permutations) in my control and then create an array of these new controls in an application…

(The idea being that I then just have to change my status property of the control and it would display the appropriate icon and the correct text etc.)

Would the system use the same images or would it be using lots of memory to store all the images in all the controls?

And what is the best way of doing this?


Thanks,
The Red Duke
 
I have been wondering about this myself. If the pictures are stored, say, in PictureBoxes, I beleived that the images would need to be loaded and instantiated from the app's embedded resources for each instance of the control, and hence duplicated.

No guarantees, but if you create a shared ImageList and load your images into the ImageList (via a shared constructor) and then set your PictureBox's .Picture property to the images from the ImageList, I believe that all six images could be shared between instances. But... I wouldn't know exactly how to do this.
 
Back
Top