Try this code. Drag a button onto your form and name it bgImage. Double click on it to generate an event handler and insert the following code.
Hope it helps!
Richard
private void bgImage_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap
(this.ClientRectangle.Width,this.ClientRectangle.H eight);
Graphics g = Graphics.FromImage(myBitmap);
g.FillRectangle(Brushes.White, this.ClientRectangle);
// 2 is the rectangle width
for (int intX = 1; (intX+2) < this.Width; intX+=10)
{
for (int intY = 1; (intY+2) < this.Height; intY += 10 )
{
//fill a rectangle that is 2 pixels wide
g.FillRectangle(Brushes.Red, intX,intY,2,2);
}
}
g.DrawString("My Custom Background", new Font(this.Font.FontFamily, 14, FontStyle.Bold), Brushes.LightGray, 30, 30);
//dispose the graphics object.
g.Dispose();
//set the bg image to the custom bitmap. Note: you can add any image to the forms background.
this.BackgroundImage = myBitmap;
this.Invalidate();
}