title: c# for-loop and Click Event Handler
body: <p>How do I use one individual event handler per iteration, without hard coding the functions?</p>
  
  <pre><code>for (int i = 0; i &lt; 100; i++)
  {
          //other code
          PictureBox listItem = new PictureBox();
          listItem.Click += new EventHandler((sender2, e2) =&gt; ListItemClicked(i));
          //other code     
  }
  </code></pre>
  
  <hr>
  
  <pre><code>private void ListItemClicked(int index)
  {
      MessageBox.Show(index.ToString());
  }
  </code></pre>