PictureBox- Grids and Filling in squares (Game of Life)
<p>I am learning C# through implementing a copy of the Game of Life. I have been able to successfully draw a grid over the <code>pictureBox</code> using for loops. The bool named <code>fill_in</code> is To fill in squares. I am requesting help in making the squares clickable. I have set the propertite attribute of <code>pictureBox</code> to allow <code>pictureBox_MouseClick</code>. In side the mouseClick event I have set the coordinates <code>x</code> and <code>y</code>. The problem is that the if statement inside that event is incorrect since <code>==</code> cannot be applied to bool operands. </p>

<p>How can I do an if condition statement that will fill with black color if the bool <code>fill_in</code> is true?</p>

<p><strong>Code</strong> </p>

<pre><code>  namespace life
    {
        public partial class Form1 : Form
        {

            Graphics paper;
            bool[,] fill_in = new bool[450, 450];

        public Form1()
            {
                InitializeComponent();
                paper = pictureBox1.CreateGraphics();

            }


    //makes grid in picture box
    private void drawGrid()
            {
                int numOfCells = 100;
                int cellSize = 10;
                Pen p = new Pen(Color.Blue);
                paper.Clear(Color.White);

                for (int i = 0; i &lt; numOfCells; i++)
                {   
                    // Vertical
                    paper.DrawLine(p, i * cellSize, 0, i * cellSize, numOfCells * cellSize);
                    // Horizontal
                    paper.DrawLine(p, 0, i * cellSize, numOfCells * cellSize, i * cellSize);
                }
            }


    // populate bool fill_in with true (alive) or false (dead)
            private void clearGrid()
            {
                for (int x = 0; x &lt; 450; x = x + 10)
                {
                    for (int y = 0; y &lt; 450; y = y + 10)
                    {
                        fill_in[x, y] = false;
                    }
                }
            }

     private void button1_Click(object sender, EventArgs e)
            {
                drawGrid();
                clearGrid();

                for (int x = 0; x &lt; 440; x = x + 10)
                {
                    for (int y = 0; y &lt; 440; y = y + 10)
                    {
                        if (fill_in[x, y] == true)
                            paper.FillRectangle(Brushes.Black, x, y, 10, 10);
                    }
                }
            }

     private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
            {

                int x = e.X;
                int y = e.Y;
                int i = x / 10;
                int j = y / 10;


                fill_in[i, j] = !fill_in[i, j];

                if (fill_in[i, j])
                {

                 paper.FillRectangle(Brushes.Black, x, y, 10, 10);
                }
                else
                {

                paper.FillRectangle(Brushes.White, x, y, 10, 10);       

                }

                }

                }
           }
</code></pre>

<p>After Changes to the if statement:</p>

<p><img src="http://i.stack.imgur.com/SMFmM.png" alt="enter image description here"></p>
