AaronASterling 0 Light Poster

Hello All,


I have a user define class,

<Serializable()> Public Class City

    Public Name As String = ""
    Public State As String = ""
    Public URL As String = ""

    Public Sub New(ByVal state As String, ByVal name As String, ByVal url As String)

       me.State = state
       me.Name = name
       me.URL = url

    End Sub
    
    Public Function isValid() As Boolean

        If me.Name <> "" And _
           me.State <> "" And _
           me.URL <> "" Then

            Return True

        Else

            Return False

        End If

    End Function

    Public Function ToSmallListViewItem() As ListViewItem

        Dim item As New ListViewItem

        item.SubItems.Add(me.State)
        item.SubItems.Add(me.Name)
        item.Tag = Me

        Return item

    End Function

End Class

From the last member function you can guess that I want to display lists of instances of this class in a listview control. Here is the code. It is a member of the main form of the application that owns the listview

Private Sub LoadMasterCityList()

        lvMasterCityList.Items.Clear()
       
       'master cities is an element of a wrapper class for List(Of City)
       'even when I bypass the wrapper and deal directly with the list as below
       'it doesn't work

        MasterCities = Cities.Load(Settings.strMasterCityListFile) 'this just loads from a file
        For Each CityItem As City In MasterCities.CityList

            'this is the listview control
            lvMasterCityList.Items.Add(CityItem.ToSmallListViewItem())

        Next

The problem is that the listview doesn't display the input. It has two columns as required by City.ToSmallListViewItem() method and is set to visible. It creates a scrollbar and I can highlight empty elements of it and scroll around. I just cant see the text. I am positive that the data is valid as it is sent to the LoadMasterCityList method, for example I have used MsgBox 's to print the contents of each CityItem both before and after the call to CityItem.ToSmallListViewItem() so I am sure that the data is write. Does anyone have any idea what can cause this behavior? I am stumped! All I have been able to find is that setting the checkbox property to true can cause a listbox too not render but I am not doing that and that is only applicable if its in large image or small image mode. It's in list mode anyway so thats not it.

Thanks in advance
Aaron

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.