CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 1999
    Posts
    1

    listview control won't list



    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

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: listview control won't list



    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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured