Click to See Complete Forum and Search --> : listview control won't list


Roger Davies
February 18th, 1999, 12:51 PM
I am attempting to use the listview control to pull up a list of icons.

In listview properties I have set the listimages to my imagelist containing the icons named by key word. Also I have set the column headings in listview properties to key to the same keys as in imagelist.


Nothing is displayed in the listview box when I run.


Is it me ? !!!!!!!


Thanks............................. Roger

Chris Eastwood
February 18th, 1999, 03:30 PM
Hi


I may be interpreting your post wrong, but are you adding any listitems to

the listview ?


You need to create the listview in the following order :


1. Assign an Imagelist to the ListView (setting Big/Small icons appropriately)

2. Set the listview to report mode

3. Add the column headings

4. Add some listitems

5. Add some listitem.subitems


Here's some sample code :


'

' Take a form, add a listview (listview1) and an Imagelist (with 5 16*16 icons)

' called imagelist1

'

Private Sub Form_Load()

Dim lCount As Long

Dim lItem As ListItem



With ListView1

.View = lvwReport

.ColumnHeaders.Add , , "Column 1"

.ColumnHeaders.Add , , "Column 2"

.ColumnHeaders.Add , , "Column 3"



End With

'

' Assuming we have 5 different icons in imagelist1

'

'

' Set .smallicons = small images list

'

' Set .Icons = big images list

'

ListView1.SmallIcons = ImageList1



With ListView1.ListItems

For lCount = 1 To 5

Set lItem = .Add(, , "List item 1", , lCount)

lItem.SubItems(1) = "Sub item 1"

lItem.SubItems(2) = "Sub item 2"

Next

End With





End Sub


If you need some more help with the listview, take a look at the VBCodeLibrary

project I posted to codeguru at :


http://www.codeguru.com/vb/articles/1634.shtml


There's all kinds of cool stuff in the project


Regards


Chris Eastwood


CodeGuru - The website for Developers

http://www.codeguru.com/vb