I have a ListView with three columns and I have added 4 records in the ListView. I would like to get the value of the 2nd column value of each record. How to implement it?
- 3It's probably more pragmatic to get the values from the underlying data source instead of from the display control.David– David2012-08-17 17:44:34 +00:00Commented Aug 17, 2012 at 17:44
- if you are loading object values in listvew then see objectlistview.sourceforge.net/cs/index.htmlRavi Patel– Ravi Patel2012-08-18 10:00:28 +00:00Commented Aug 18, 2012 at 10:00
Add a comment |
4 Answers
loop through all the rows and try this.
Subitems[columnnumber] will be the column numbr of the required field
lv.Items[i].SubItems[1].Text
2 Comments
Shankar G
yeah i did like this but the loop is not executed. here is my code for(int i=0;i<=listview1.Items.Count;i++) { listview1.Items[i].Selected = true; string path = sch.m_playlist.SelectedItems[i].SubItems[1].Text; MessageBox.Show(path); }
ygssoni
Are you trying to do this? -
for(int i=0;i<=listview1.Items.Count;i++) { string path = listview1.Items[i].SubItems[1].Text; MessageBox.Show(path); }