ListViewItems SubItems

  • Thread starter Thread starter Gianmaria Iaculo - NETLABS
  • Start date Start date
G

Gianmaria Iaculo - NETLABS

Hi,
On a Form i have a ListView where elements have name, surname and so on.
Down this list i have to textBoxes, so when the selectedIndex of the
listview changes.. the two text boxes are filled in with the values name and
surname (subitems of listview Items). Now it happen that if i move with the
keyboard from one element to an other one.. it gives me an out of range
error.
where i go wrong?


regards
Gian
 
this is my code..

private void listView1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
this.txtName.Text = this.listView1.SelectedItems[0].SubItems[0].Text;
this.txtSurname.Text = this.listView1.SelectedItems[0].SubItems[1].Text;
}

Each item in the list have 7 subitems... the info i add in each column of
the listView.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top