Drawing Question

  • Thread starter Thread starter Jared Miniman [MVP]
  • Start date Start date
J

Jared Miniman [MVP]

Let's say my form has an ImageList, and I wish at runtime, to dynamically
create some drawing objects (for simplicity sake a filled rectangle) and
fill up my ImageList with those objects. Is this feasible? Could someone
point me to some sample code to illustrate this?

--
_________________________________
Jared Miniman
MS-MVP Mobile Devices
Accenture Mobile Solutions Group

ActiveSync problems?
http://www.microsoft.com/mobile/pocketpc/support/help/activesync.asp
Connection Mngr Q's?
http://www.microsoft.com/mobile/pocketpc/tutorials/connectionmanager
 
It is possible. Create a new Bitmap object. Create a Graphics object on it
using Graphics.FromImage. Draw whatever you want on this bitmap. Destroy
Graphics object. Set the bitmap as one of the ImageList images
 
Jared Miniman said:
Let's say my form has an ImageList, and I wish at runtime, to dynamically
create some drawing objects (for simplicity sake a filled rectangle) and
fill up my ImageList with those objects. Is this feasible? Could someone
point me to some sample code to illustrate this?

This is off my mind, so it might be wrong:

using System.Drawing;

Bitmap bmp = new Bitmap(64,64);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(new SolidBrush(Color.FromArgb(0xFF0000)),0,0,64,64);
imageList1.Images.Add(bmp);
g.Dispose();

And that should do it

Hope this helps,

- Javier Campos
 
Back
Top