Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleUse the ListView control
KeywordsListView, ImageList
CategoriesControls
 
Use the ListView control's ColumnHeaders collection's Add method to add columns to the control. Use TextWidth to determine the columns' widths.

Set the control's Icons and SmallIcons properties equal to ImageList controls holding the images the ListView should use for its large and small icons.

Use the control's ListItems collection's Add method to make new rows. Set a row's Icon and SmallIcon properties to give the indexes of the images the row should use in the ImageList controls. Set the row's SubItems values to add data.

 
Private Sub Form_Load()
Dim column_header As ColumnHeader
Dim list_item As ListItem

    ' Create the column headers.
    Set column_header = ListView1. _
        ColumnHeaders.Add(, , "Abbrev", _
        TextWidth("Abbrev"))
    Set column_header = ListView1. _
        ColumnHeaders.Add(, , "Title", _
        TextWidth("Ready-to-Run Visual Basic Algorithms"))
    Set column_header = ListView1. _
        ColumnHeaders.Add(, , "ISBN", _
        TextWidth("0-000-00000-0"))

    ' Start with report view.
    mnuViewChoice_Click lvwReport

    ' Associate the ImageLists with the
    ' ListView's Icons and SmallIcons properties.
    ListView1.Icons = imgLarge
    ListView1.SmallIcons = imgSmall

    Set list_item = ListView1.ListItems.Add(, , "VBA")
    list_item.Icon = 1
    list_item.SmallIcon = 1
    list_item.SubItems(1) = "Ready-to-Run Visual Basic " & _
        "Algorithms"
    list_item.SubItems(2) = "0-471-24268-3"

    Set list_item = ListView1.ListItems.Add(, , "VBGP")
    list_item.Icon = 1
    list_item.SmallIcon = 1
    list_item.SubItems(1) = "Visual Basic Graphics " & _
        "Programming"
    list_item.SubItems(2) = "0-471-15533-0"

    Set list_item = ListView1.ListItems.Add(, , "CCL")
    list_item.Icon = 1
    list_item.SmallIcon = 1
    list_item.SubItems(1) = "Custom Controls Library"
    list_item.SubItems(2) = "0-471-24267-5"

    Set list_item = ListView1.ListItems.Add(, , "AVBT")
    list_item.Icon = 1
    list_item.SmallIcon = 1
    list_item.SubItems(1) = "Advanced Visual Basic " & _
        "Techniques"
    list_item.SubItems(2) = "0-471-18881-6"
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated