title: c# listview selected item how to
body: <p>I have a listview control I would reliably want to get the selected property off. My code</p>
  
  <pre><code>private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  {
          label1.Text = listView1.SelectedItems[0].Text;
          label1.Tag = listView1.SelectedItems;
          textBox2.Text = listView1.SelectedItems[0].SubItems[1].Text;  
      textBox3.Text = listView1.SelectedItems[0].SubItems[2].Text;
  }
  </code></pre>
  
  <p>This works well but when you click the second time or change the selection the program fails with error on the </p>
  
  <pre><code> label1.Text = listView1.SelectedItems[0].Text; 
  </code></pre>
  
  <p>How to get this fixed so that it does not fail the second time round.</p>