title: 2 Dynamic Buttons, 1 Event Handler. How to determine who clicked the event?
body: <p>I'm trying to determine from my 2 dynamic buttons who click the event handler.</p>
  
  <p>How i create my 2 dynamic buttons at Form load</p>
  
  <pre><code>private void Form1_Load(object sender, EventArgs e)
      {     
          for (int q = 0; q &lt; 2; q++)
          {
              Point newLoc = new Point(a, b);              
              for (int i = 0; i &lt;= 3 - 1; i++)
              {
                  buttonArray[i] = new Button();
                  buttonArray[i].Size = new Size(95, 80);
                  buttonArray[i].Name = "btn" + q;
                  buttonArray[i].Text = "btn" + q;
                  buttonArray[i].Click += newButton;
                  buttonArray[i].Location = newLoc;
                  a = a + 10;
                  if (a &gt; 300)
                  {
                      b = b + 100;
                      a = 1;
                  }
                  this.Controls.Add(buttonArray[i]);
              }
          }                 
      }
  </code></pre>
  
  <p>The Event I'm trying to call</p>
  
  <pre><code>   void newButton(object sender, EventArgs e)
      {
          if (sender == "btn1")
          {
              MessageBox.Show("btn1");          
          }
  
          if (sender == "btn2")
          {
              MessageBox.Show("btn2");
          }
      }
  </code></pre>
  
  <p>It can call the event handler if I do not add the IF statement.</p>