ListView / Show Any Subitem

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.
 
T

Trebek

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
 
P

Paddy

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

Top