08-18-2011, 12:33 PM
I'm trying to add items to a ListView control.
I have 2 columns, the second, entitled "Name" being the main column, which will display the name of the file added, and the first showing the number of the item.
iTunes is a good example of what I'm after, only without the checkboxes:
I'm a newbie when it comes to using the ListView control and I'm finding it a total nightmare. Here's my code so far:
Which for some reason, when adding the first item, instead of displaying "1", it displays the OFD.FileName, however when I add the second item, it works and displays the number "2".
Any help with this?
I have 2 columns, the second, entitled "Name" being the main column, which will display the name of the file added, and the first showing the number of the item.
iTunes is a good example of what I'm after, only without the checkboxes:
I'm a newbie when it comes to using the ListView control and I'm finding it a total nightmare. Here's my code so far:
Code:
Dim item As New ListViewItem()
Dim i As Integer = lst1.Items.Count
lst1.Items.Add(item)
item.Text = i + 1
Dim l As Integer = item.SubItems.Count
item.SubItems.Add(OFD.FileName)
lst1.Items(0).SubItems(l - 1).Text = OFD.FileName
Which for some reason, when adding the first item, instead of displaying "1", it displays the OFD.FileName, however when I add the second item, it works and displays the number "2".
Any help with this?