Listview subitems

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

How do I get the sub item value?
There is no "Item" property of the subitem?

foreach (ListViewItem lvItem in lvItems.Items)

//This doesn't work

myValue=lvItem.SubItems.Item(1).Value
 
How do I get the sub item value?
There is no "Item" property of the subitem?

foreach (ListViewItem lvItem in lvItems.Items)

//This doesn't work

myValue=lvItem.SubItems.Item(1).Value

It can alkso be done as


lstvew.item.subitem.text
Well I think it may and am not sure
 
How do I get the sub item value?
There is no "Item" property of the subitem?

foreach (ListViewItem lvItem in lvItems.Items)

//This doesn't work

myValue=lvItem.SubItems.Item(1).Value

I don't know what planet your list view comes from, but where I'm from,
ListViewSubItem objects do not have a Value property.... (Maybe it's a 3.5
thing?)

Anyways, you can go the shorter route through the indexer:

myValue = lvItem.SubItems[1].Text;

And remember, SubItems[0] is the same as the ListViewItem itself, as least
as far as the things you can access through a SubItem are concerned. In
other words,

lvItem.SubItems[0].Text

gets the same value as

lvItem.Text
 
Back
Top