How to draw 8X8 matrix of box frames (WinForms) in C#

1 Answer

0 votes
using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            int x, y = 10, w = 50, h = 50;

            Pen pen = new Pen(Color.Black, 2);

            for (int i = 1; i <= 8; i++)
            {
                x = 10;
                for (int j = 1; j <= 8; j++)
                {
                    Graphics g = this.CreateGraphics();
                    g.DrawRectangle(pen, new Rectangle(x, y, w, h));
                    x += 50;
                    g.Dispose();
                }
                y += 50;
            }
            pen.Dispose();
        }
    }
}



answered Feb 9, 2015 by avibootz
edited Feb 9, 2015 by avibootz

Related questions

1 answer 334 views
1 answer 2,105 views
1 answer 280 views
...