Valhalla Legends Forums Archive | .NET Platform | [VB.Net] ListView Columns

AuthorMessageTime
mentalCo.
Ok say you have a listview, "lvwChannel", with two columns, "colUsername" and "colPing".  How do you insert an item into the second column ("colPing")?
October 21, 2004, 2:19 PM
Myndfyr
Use the ListViewItem.SubItems collection:

[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewitemclasssubitemstopic.asp[/url]
October 21, 2004, 2:49 PM
Imperceptus
So yeah uhm what you need to know is that the column is a subitem, and you want to change the subitems text value
example "probally dont compile"
[code]
listview.listitems.listsubitems.text
[/code]
or soemthing along those lines, you really need to search the forums.... I learned how to use the listview from these forums using just the search tool.
October 22, 2004, 7:46 PM
Myndfyr
You access it like a collection:

[code]
MyListView.ListItems(ItemIndex).SubItems(ColumnIndex).Text = "Value"
[/code]
October 23, 2004, 8:49 AM
Imperceptus
was trying to not give the exact answer but point to what they would need to head in the right direction.  But yeah, thats it.  Good to know that you cannot refer to the column index as 0.  returns error.  If you want to return the text for the first column its
[code]
MyColumnOneValue = MyListView.ListItems(ItemIndex).Text
[/code]
October 23, 2004, 6:22 PM

Search