I call the following code:
VB.Net Code:
Public Sub LoadXML(ByVal file As String, ByVal ListViewName As ListView) Dim XMLfile As New XmlTextReader(file) XMLfile.WhitespaceHandling = WhitespaceHandling.None XMLfile.Read() XMLfile.Read() While Not XMLfile.EOF If Not XMLfile.IsStartElement() Then 'Check it's actually a tag and not crap. Exit While End If Dim X As New ListViewItem Dim FileName = XMLfile.GetAttribute("fn") XMLfile.Read() Dim artist = XMLfile.ReadElementString("artist") Dim title = XMLfile.ReadElementString("title") Dim album = XMLfile.ReadElementString("album") X = ListViewName.Items.Add(FileName) X.SubItems.Add(artist) X.SubItems.Add(title) X.SubItems.Add(album) End While XMLfile.Close() End Sub
Using the following call:
VB.Net Code:
LoadXML("C:\Users\Dev\Documents\Sample.XML", Form2.ListView2)
However, no errors are shown, the items are not added to the ListView.
Also, if i check the values of "artist", it is populated, as are the rest.
It just, for some reason, does not add to a listview on another form.




Reply With Quote