views:

122

answers:

2

I'm developing a VB.NET WinForms application, and I'm using lots of small 16x16 32bit icons everywhere; most of which are nested behind tabs or otherwise invisible. I'm putting all of them in one big ImageList control, it seems easier to manage them from there.

My question is, is this smart? I'm using the imagelist even in buttons, and controls that could otherwise have an image assigned more directly (e.g., through the Image property).

Note that I use ImageKey and have no (current) need for ImageIndex.

Does it have a negative/positive effect on performance?

+2  A: 

I don't think performance will probably be an issue, but if you're looking for a centralized location for storing your images, why not use embedded resources?

Here's a VB.NET-specific example:

http://www.devx.com/vb2themax/Tip/18838

Andy West
That's my current approch, but I seldom define resources from code, since ImageLists were supposedly made to make runtime Image changes easier (Or so I've read in About.com when I came across uses for ImageLists). I use resources mainly on design-time.
Camilo Martin
+1  A: 

Unless you have a billion icons, you're not likely to have any problems with storage or performance.

Really it comes down to the organisational approach you find easiest. Sometimes a shared repository is convenient, but it can be a hassle if the resources for a control are stored in an unrelated location.

In general I'd just drop the icons into your resources and then set the Icon/Image property on your controls to point at them - this is just a much easier way of managing the resources. But if you find your approach easier (having tried out the alternatives), then go for it.

Jason Williams
Well, I used to do it that way, but having too much resources makes them hard to navigate for me. That's why I find easier to have ImageLists =)
Camilo Martin
Thanks! =) I was mainly worried about it being specially good or bad from a performance viewpoint.
Camilo Martin
It's unlikely - e.g. if you click a tab, as long as it changes to the new tab within about a quarter of a second, the user won't think it's too slow. You can do an awful lot of work in a quarter of a second!
Jason Williams
Very true. Also, most hogs are due to using the same CPU thread for everything =P (I never liked how background workers and delegates are overly complicated (considering this is .NET) though)
Camilo Martin