就像下图一样:写代码实现,而不是加个背景图片。谢谢?

解决方案 »

  1.   

    就用Graphics,一个for循环就搞定.
      

  2.   

    绘制?
    这是一个在PictureBox控件上绘制的代码
                pictureBox1.Image = new Bitmap(400, 400);
                Graphics gr = Graphics.FromImage(pictureBox1.Image);
                bool IsWhite = true;
                for(int h=0;h<400;h+=10)
                    for (int w = 0; w < 400; w += 10)
                    {
                        if (IsWhite)
                        {
                            gr.FillRectangle(Brushes.White, new Rectangle(new Point(w, h), new Size(10, 10)));
                            IsWhite = false;
                        }
                        else
                        {
                            gr.FillRectangle(Brushes.Gray, new Rectangle(new Point(w, h), new Size(10, 10)));
                            IsWhite = true;
                        }
                    }
                gr.Dispose();
      

  3.   

     private void Form1_Load(object sender, EventArgs e)
            {
                pictureBox1.Image = new Bitmap(400,400);
                Graphics gr = Graphics.FromImage(pictureBox1.Image);
                bool IsWhite = true;
                for (int h = 0; h < 400; h += 10)
                {
                    if ((h / 10) % 2 == 0)
                    {
                        IsWhite = false;
                    }
                    else
                    {
                        IsWhite = true;
                }
                    for (int w = 0; w < 400; w += 10)
                    {
                        if (IsWhite)
                        {
                            gr.FillRectangle(Brushes.White, new Rectangle(new Point(w, h), new Size(10, 10)));
                            IsWhite = false;                    }
                        else
                        {
                            gr.FillRectangle(Brushes.Gray, new Rectangle(new Point(w, h), new Size(10, 10)));
                            IsWhite = true;                    }
                
                   
                    }
                   
                }
      

  4.   

    就用Graphics,一个for循环就搞定.