Hi guys,
Need desperate advice on how to use listview boxes in report mode. Manage to create some columnheaders but i simple can't find the way to add items.
Printable View
Hi guys,
Need desperate advice on how to use listview boxes in report mode. Manage to create some columnheaders but i simple can't find the way to add items.
Maybe you can pick this apart.
Code:'create obj var for columnHeader obj and listitem obj
Dim sColumn As ColumnHeader
Dim sItem As ListItem
'
'start in report view
Listview1.View = lvwReport
'
'set the size and pos of the listview
'
Listview1.Width = ScaleWidth
Listview1.Height = ScaleHeight
Listview1.Top = ScaleTop
Listview1.Left = ScaleLeft
'
'set the list ctrl icon properties
'this initializes the image list
Listview1.Icons = ilsLargeIcons
Listview1.SmallIcons = ilsSmallIcons
'
'add columnHeaders..the width of the columns is
'the widht of the ctrl / 2 by the num of headers
'
Set sColumn = Listview1.ColumnHeaders.Add(, , "Name")
Set sColumn = Listview1.ColumnHeaders.Add(, , "Phone #1")
Set sColumn = Listview1.ColumnHeaders.Add(, , "Phone #2")
'
'add some data to the listitem (sItem)
Set sItem = Listview1.ListItems.Add(, , "Kim & Deb", 1, 1)
sItem.SubItems(1) = "905-799-9415"
sItem.SubItems(2) = "who knows"
'second name Remove the 1,1 to show no icons
Set sItem = Listview1.ListItems.Add(, , "Phil & Tony", 1, 2)
sItem.SubItems(1) = "416-000-0099"
sItem.SubItems(2) = "who knows"
'third item
Set sItem = Listview1.ListItems.Add(, , "Jamie & Lana")
sItem.SubItems(1) = "905-444-9455"
sItem.SubItems(2) = "who knows"
'
'
' How to Populate the list with data via code
'fill an array with information
Dim myArr(99)
Dim i As Integer
For i = 1 To 99
myArr(i) = CInt(Rnd * 99)
Next i
'then load the array
For i = 1 To 99
'used different images every second line
'image one for odd, image2 for even
If i Mod 2 <> 0 Then
Set sItem = Listview1.ListItems.Add(, , myArr(i), 1, 1)
Else
Set sItem = Listview1.ListItems.Add(, , myArr(i), 2, 2)
End If
'add subitems
sItem.SubItems(1) = "905-444-9455"
sItem.SubItems(2) = "who knows"
Next i
Hi, tried your method but the compiler says that the image list is not initialised. Pls help.
Remove the last two numbers from every add.
They're numbers to add icons from an imagelist.Code:Dim sItem As ListItem
Set sItem = Listview1.ListItems.Add(, , "Kim & Deb")
sItem.SubItems(1) = "905-799-9415"
sItem.SubItems(2) = "who knows"