Support Forums
[Help] - ListView Control - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: [Help] - ListView Control (/showthread.php?tid=21527)



[Help] - ListView Control - Fragma - 08-18-2011

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:
[Image: itunes.png]

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".

[Image: swfapp.png]

Any help with this?



RE: [Help] - ListView Control - Fragma - 08-18-2011

Anybody help me out with this? It's doing my head in.


RE: [Help] - ListView Control - Fragma - 08-19-2011

Never mind, got it working in the end.