title: c# event handler on a listview
body: <p>I would like to create an event handler in a listview. I mean I would like to call a function every time I have a new element in my listview. Can someone help me how to do it? I don't need a click event handler. The event handler I would like it to be automatically generated by the code (the ithem from the listview to be selected and then a new method to be called). The element in the listview looks like: <code>element1 name surname</code> (this is on the first row). THx</p>
  
  <p>How to create the handler for this function ? </p>
  
  <pre><code>private void listview1_SelectedIndexChanged(object sender, EventArgs e)
  { 
     for (int x = 0; x &lt; listview1.Items.Count; x++)
     { 
        if (listview1.Items[x].Selected) 
           MessageBox.Show(listview1.Items[x].SubItems[1].Text);
     }
  }
  </code></pre>