//网格宽300,高600
Bitmap image = new Bitmap(300,600);
//创建绘图对象Graphics
Graphics graphics = Graphics.FromImage (image);
//清除画布,背景颜色为红色
graphics.Clear(Color.Red);
//通过循环画出横线
for (int i = 0; i < 30; i++)
{
graphics.DrawLine(new Pen(Brushes.Black, 1), 0, i * 20, 300, i * 20);
}
//通过循环画出竖线
for (int i = 0; i < 20; i++)
{
graphics.DrawLine(new Pen(Brushes.Black, 1), i * 20, 0, i * 20, 600);
}
this.BackgroundImage = image;
//加边框
graphics.DrawRectangle(new Pen(Color.Black), 0, 0, image.Width - 1, image.Height - 1);
//设置图片平铺方式
this.BackgroundImageLayout = ImageLayout.None;