title: selecting item from listview in C#
body: <p>I am trying to select an item from a list view and it should display each in a text box as I select it. I am able to select and get first item but when I select the second item I am getting an error,</p>
  
  <p>"Argument out of range exception was unhandled, InvalidArgument=Value of '0' is not valid for 'index'."</p>
  
  <p>I have my below code, please help me.. </p>
  
  <pre><code>public partial class Form2 : Form
  {
    List&lt;Person&gt; people = new List&lt;Person&gt;();
  }
  
  class Person
  {
    public string Name{ get; set; }
  
    private void button2_Click(Object sender, EventArgs e)
    {
      Person p = new Person();
      p.Name = textBox1.Text;
      people.Add(p);
      listBox1.Items.Add(p.Name);
    }
  
    private void listView1_SelectedIndexChanged(object sender, EventArgs e)
    {
      textBox1.Text = people[listView1.SelectedItems[0].Index].Name;
    }
  }
  </code></pre>