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.
 
Back
Top