| | |
Problems instering items into a listview
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
Hello All,
I have a user define 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
The problem is that the listview doesn't display the input. It has two columns as required by [inlinecode=vb]City.ToSmallListViewItem()[/inlinecode] 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 [inlinecode=vb]LoadMasterCityList[/inlinecode] method, for example I have used [inlinecode=vb]MsgBox[/inlinecode]'s to print the contents of each [inlinecode=vb]CityItem[/inlinecode] both before and after the call to [inlinecode=vb]CityItem.ToSmallListViewItem()[/inlinecode] 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
I have a user define class,
vb Syntax (Toggle Plain Text)
<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
vb Syntax (Toggle Plain Text)
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 [inlinecode=vb]City.ToSmallListViewItem()[/inlinecode] 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 [inlinecode=vb]LoadMasterCityList[/inlinecode] method, for example I have used [inlinecode=vb]MsgBox[/inlinecode]'s to print the contents of each [inlinecode=vb]CityItem[/inlinecode] both before and after the call to [inlinecode=vb]CityItem.ToSmallListViewItem()[/inlinecode] 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
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: To check for a particr extension in a given folder
- Next Thread: error
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dropdownlist excel fade file-dialog folder ftp generatetags google hardcopy image images input insert intel internet login mobile monitor ms net networking objects opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial shutdown soap string survey tcp temperature text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





