Please Help: Add items to listview from XML File

G

Guest

I have difficulties in retreiving the data from XMl file that i have created. By using the coding as below, i m able to retrieve only 2 fields and display it in the listview

Below are my coding and XML file that i have created

CODING

Private Sub RegisterListView(
Dim item As ListViewIte

lvwDisplay.Items.Clear(

For Each row As DataRow In TransTable.Row
item = New ListViewItem(row("Category").ToString()
If Not (row("Type") Is Nothing) The
item.SubItems.Add(String.Format("{0:F2}", row("Type").ToString())
End I

lvwDisplay.Items.Add(item
Next ro
End Su

XML Fil

-<Table1><Desc>566</Desc><Category>ttgg</Category><Type>Deposit</Type><Amount>667</Amount></Table1
- <Table1><Desc>tt6t</Desc><Category>rrt</Category><Type>Decrease</Type><Amount>566</Amount></Table1>
 
P

Peter Foot [MVP]

Have you set up enough columns in the ListView control to display the
columns you want from the table? If so then just add additional lines for
each extra SubItem you want to add to each row e.g.

Private Sub RegisterListView()
Dim item As ListViewItem

lvwDisplay.Items.Clear()

For Each row As DataRow In TransTable.Rows
item = New ListViewItem(row("Category").ToString())

item.SubItems.Add(row("Type").ToString())
item.SubItems.Add(row("Amount").ToString())
'etc

lvwDisplay.Items.Add(item)
Next row
End Sub

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

-yEaN- said:
I have difficulties in retreiving the data from XMl file that i have
created. By using the coding as below, i m able to retrieve only 2 fields
and display it in the listview.
Below are my coding and XML file that i have created.

CODING

Private Sub RegisterListView()
Dim item As ListViewItem

lvwDisplay.Items.Clear()

For Each row As DataRow In TransTable.Rows
item = New ListViewItem(row("Category").ToString())
If Not (row("Type") Is Nothing) Then
item.SubItems.Add(String.Format("{0:F2}", row("Type").ToString()))
End If

lvwDisplay.Items.Add(item)
Next row
End Sub


XML File

-<Table1><Desc>566</Desc><Category>ttgg</Category><Type>Deposit</Type><Amo
unt>667 said:
<Table1><Desc>tt6t</Desc><Category>rrt</Category><Type>Decrease</Type><Amoun
t>566</Amount></Table1>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top