ListView / Show Any Subitem

  • Thread starter Thread starter Paddy
  • Start date Start date
P

Paddy

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

This will display sub item [1] after cklicking on item [0]
I want to display subitem[1] of any item I click on
how do I do that?
Many thanks.
Paddy.
 
Cast the sender into a ListView (or simply refer to your ListView instance)

ListView lv = sender as ListView;

Get the SelectedItem and refer to it's subitem at position 0

ListViewItem lvi = lv.SubItems[1];

etc etc etc ....

Alex
 
Hi Trebek.

This doesn't compile.

Error: ListView does noy contain a definition for SubItems

:(

Please help some more.

Paddy


Trebek said:
Cast the sender into a ListView (or simply refer to your ListView instance)

ListView lv = sender as ListView;

Get the SelectedItem and refer to it's subitem at position 0

ListViewItem lvi = lv.SubItems[1];

etc etc etc ....

Alex





Paddy said:
private void listView1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
textBox1.Text = this.listView1.Items[0].SubItems[1].Text;
}

This will display sub item [1] after cklicking on item [0]
I want to display subitem[1] of any item I click on
how do I do that?
Many thanks.
Paddy.
 

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

Similar Threads

Viewing subitem in listview 1
Question about sorting 5
ListView problem 3
better way to change a string 2
Listview subitems 3
set checkboxes in listview from list 1
listView question 7
ListViewSort question 1

Back
Top