tags:

views:

138

answers:

3

Im making a little app to display the pictures of guests as they scan their cards. But i want to to display blank green or red (green if the guest exists without a photo and red if they dont exist)

But i cant figure out how to create a blank colour image.

Bitmap bmRed = new Bitmap(imgbox.Width, imgbox.Height, PixelFormat.Format24bppRgb);
imgbox.Image = bmRed;

Thats the code i have at the moment and it just makes the box black. imgbox is a PictureBox

A: 

create a graphics context and draw using it.

using(Graphics g = Graphics.FromImage(bmRed))
{
  g.FillRectangle(new SolidBrush(Color.Red),0,0,imgbox.Width,imgbox.Height);
}
Andrew Keith
+2  A: 

Don't use an image - set the BackColor property of the PictureBox:

imgBox.BackColor = Color.Red;
Jay Riggs
hahahahhaha didnt realise it was that easy! thanks guys
d1k_is
+1  A: 

How about setting the background color directly?

imgbox.BackColor = Color.Red;
micahtan