title: how to draw something on a panel by clicking a button
body: <p>i have a panel and a button. i.e:</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
      {
          panel2.Paint += new PaintEventHandler(panel2_Paint);
          panel2.Refresh();
      }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>private void panel2_Paint(object sender, PaintEventArgs e)
      {
  
  
              Graphics g = this.CreateGraphics();
              Graphics[,] g1 = new Graphics[140, 140];
              int[,] graph = new int[140, 140];
  
              int i, j;
              for (i = 0; i &lt; 140; i++)
                  for (j = 0; j &lt; 140; j++)
                  {
                      graph[i, 8] = 1;
                      graph[i, 10] = 1;
                  }
  
              Pen p = new Pen(Color.Blue);
              SolidBrush mySolidColorBrush = new SolidBrush(Color.Blue);
              Graphics a;
              a = this.CreateGraphics();
  
              for (i = 1; i &lt;= 10; i++)
                  for (j = 1; j &lt;= 14; j++)
                  {
                      g.DrawEllipse(p, 80 * i, 80 * j, 10, 10);
                    g.FillEllipse(mySolidColorBrush, 80 * i, 80 * j, 20, 20);
            a.DrawLine(Pens.Blue, 80 * i, 80 * j, 80 * (i - 1), 80 * (j - 1));
                  }
  
      }
  </code></pre>
  
  <p>when i click the button the output should be displayed on panel but in my case it is displayed on form.</p>