Results 1 to 2 of 2

Thread: Newbe ListView question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    I just discovered the ListView control and want to know how to add items to it.. I don't have access to my MSDN cd right now so I can't lookup the help..

    My idea is to populate the listview from data in an Access table via ADO.. I don't need help on accessing the database, just help on populating the listview with an ADO recordset..

    Any examples or help would be appreciated..

    Dan

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    'just change the items form the rnd to rs!fields

    Code:
        Dim l As Long
        Dim dblRnd As Double
        Dim dteRnd As Date
        With ListView1
            ' Add three columns to the list - one for each data type.
            ' Note that the data type is set in the column header's
            ' tag in each case
    '
            .ColumnHeaders.Add(, , "String").Tag = "STRING"
            .ColumnHeaders.Add(, , "Number").Tag = "NUMBER"
            .ColumnHeaders.Add(, , "Date").Tag = "DATE"
    '
            ' Set the column alignment - has no bearing on the sorts.
    '
            .ColumnHeaders(1).Alignment = lvwColumnLeft
            .ColumnHeaders(2).Alignment = lvwColumnRight
            .ColumnHeaders(3).Alignment = lvwColumnCenter
    '
    ' Set BorderStyle property.
       ListView1.BorderStyle = ccFixedSingle
    '
    ' Set View property to Report.
       ListView1.View = lvwReport
    '
            ' Populate the list with data
            With .ListItems
                For l = 1 To 100
                    With .Add(, , "ListItem " & Format(l, "0000"))
                        dblRnd = (Rnd() * 10000) - 5000
                        dteRnd = (Rnd() * 1000) + Date
                        .ListSubItems.Add , , Format(dblRnd, "0.00")
                        .ListSubItems.Add , , Format(dteRnd, _
                        "dd/mm/yyyy")
                    End With
                Next l
            End With
        End With
    '
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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