Extracting subitems from a listview?
-
I've got a listview control on a windows form. The listview is loaded with data. Is there a way to get the string data from each subitem when the user clicks on a row in the listview? For example: row 3 in the listview has Smith, John, and 22-3333-53 in it. I'd like to get the strings Smith, John, and 22-3333-53 returned from the listview. Is this possible? I haven't seen a thing on the code project about it. Thanks
-
I've got a listview control on a windows form. The listview is loaded with data. Is there a way to get the string data from each subitem when the user clicks on a row in the listview? For example: row 3 in the listview has Smith, John, and 22-3333-53 in it. I'd like to get the strings Smith, John, and 22-3333-53 returned from the listview. Is this possible? I haven't seen a thing on the code project about it. Thanks
Yep!!! Each ListViewItem in the ListViewItemsCollection (
myListView.Items
) has aSubItems
collection too... :-D You just dostring Surname = listView.Items[2].Text; string Forename = listView1.Items[2].SubItems[0].Text string Phone = listView1.Items[2].SubItems[1].Text
HTH Cheers :-D Shaun -
Yep!!! Each ListViewItem in the ListViewItemsCollection (
myListView.Items
) has aSubItems
collection too... :-D You just dostring Surname = listView.Items[2].Text; string Forename = listView1.Items[2].SubItems[0].Text string Phone = listView1.Items[2].SubItems[1].Text
HTH Cheers :-D Shaun -
No probs... :-D Any time!!! ;)