title: ListView selected item to TextBox
body: <p>First, I have filled a list object with the data from xml file. After that, I have filled a <code>ListView</code> with the necessary fields, without any problem. How can I get the index from the selected <code>ListView</code> item and then give appropriate value to some textbox?</p>
  
  <p>This is the code for it:</p>
  
  <pre><code>private void Form1_Load(object sender, EventArgs e)
  {
  
      List&lt;Tasks&gt; taskList = new List&lt;Tasks&gt;();
  
      listView1.Columns.Add("Date:");
      listView1.Columns.Add("Job:");
      listView1.Columns.Add("Client Name");
      listView1.Columns.Add("Submitted by");
  
      taskList = getTasks();
  
      listView1.Items.Clear();
  
      for (int i = 0; i &lt; taskList.Count; i++)
      {
          Tasks task = taskList.ElementAt(i);
  
          ListViewItem row = new ListViewItem();
          row.Text=task.date.ToString();
          row.SubItems.Add(task.job);
          row.SubItems.Add(task.clientName);
          row.SubItems.Add(task.submittedBy);
  
          listView1.Items.Add(row);
      }
  }
  
  public List&lt;Tasks&gt; getTasks()
  {
      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.Load("data.xml");
  
      XmlNodeList nodes = xmlDoc.DocumentElement.SelectNodes("/tasks/task");
  
      List&lt;Tasks&gt; taskList = new List&lt;Tasks&gt;();
  
      foreach (XmlNode node in nodes)
      {
          Tasks task = new Tasks();
          task.id = Convert.ToInt32(node.SelectSingleNode("id").InnerText);
          task.date = Convert.ToDateTime(node.SelectSingleNode("submittedDate").InnerText);
          task.submittedBy = node.SelectSingleNode("submittedBy").InnerText;
          task.clientName = node.SelectSingleNode("clientName").InnerText;
          task.job = node.SelectSingleNode("job").InnerText;
          task.taskCategory = node.SelectSingleNode("taskCategory").InnerText;
          task.taskDescription = node.SelectSingleNode("taskDescription").InnerText;
          task.hours = node.SelectSingleNode("hours").InnerText;
          task.status = node.SelectSingleNode("status").InnerText;
          task.isBilled = node.SelectSingleNode("isBilled").InnerText;
          task.cost = node.SelectSingleNode("cost").InnerText;
          task.followUpInfo = node.SelectSingleNode("followUpInfo").InnerText;
          task.invoiceNumber = node.SelectSingleNode("quickBooksInvoiceNo").InnerText;
  
         taskList.Add(task);
      }
  
      return taskList;
  }
  
  private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  {
  
  }
  </code></pre>
  
  <p>What I need is now how when I click an item from the <code>listView1</code> to show some value in a textbox? But that value should be taken from the list object <code>taskList</code>, not from the xml document itself.</p>