views:

2764

answers:

2

I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs.

I'd really like to avoid having to hand-generate all the possibly permutations of status icons if I can avoid it.

Is it possible to create an image list (or just a bunch of bitmap resources or something) that I can use to generate the ImageList programmatically?

I'm poking around the System.Drawing classes and nothing's jumping out at me. Also, I'm stuck with .Net 2.0.

+1  A: 
Bitmap image1 = ...
Bitmap image2 = ...

Bitmap combined = new Bitmap(image1.Width, image1.Height);
using (Graphics g = Graphics.FromImage(combined)) {
  g.DrawImage(image1, new Point(0, 0));
  g.DrawImage(image2, new Point(0, 0);
}

imageList.Add(combined);
Hallgrim
A: 

Just use Images.Add from the ImageList to add in the individual images. So, something like:


Image img = Image.FromStream( /*get stream from resources*/ );
ImageList1.Images.Add( img );
Joel Lucsy