Problem with adding items to a listview in code

  • Thread starter Thread starter JamesL
  • Start date Start date
J

JamesL

I have a listview object on a form. I read lines out of a text file and
want to add them to the listview.
I used the following code. The problem I run into is that while the help
file tells me to put a string in the lvwobject.items.add(string,0) when I
actually do it, the code widow tells me I have to put a listviewitem in the
items.add line. So what is the right way to add the text to the listview?
Dim ExpDate As String

Dim Expense As String

Dim Amt As String

Dim Pmt As String

Dim objListItem As ListViewItem

objListItem = lvwExpenses.Items.Add(ExpDate, 0)

objListItem.SubItems.Add(Expense)

objListItem.SubItems.Add(Amt)

objListItem.SubItems.Add(Pmt)



James Lysaght
 
In CF 1.0 ListView.Items.Add requires a ListViewItem to be passed as a
parameter.

Dim ExpDate As String

Dim Expense As String

Dim Amt As String

Dim Pmt As String

Dim objListItem As new ListViewItem(ExpDate)

objListItem.SubItems.Add(Expense)

objListItem.SubItems.Add(Amt)

objListItem.SubItems.Add(Pmt)

lvwExpenses.Items.Add(objListItem)
 
Back
Top