Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

optimize a listview filling

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
423
IT
Code:
 Private Sub FILL_LISTVIEW()

    RSTADO.MoveFirst

    Erase STRDBROWS()
    STRDBROWS = RSTADO.GetRows(RSTADO.RecordCount)
    RSTADO.Close
    Set RSTADO = Nothing

    With Me.ListView1

        SendMessage Me.hwnd, WM_SETREDRAW, SR_OFF, 0&

        .ListItems.Clear

        For I = 0 To UBound(STRDBROWS, 2)
            DoEvents
            Set ITMX = .ListItems.Add(, , UCase(STRDBROWS(0, I)))
            For L = 1 To 61
                ITMX.SubItems(L) = Replace(UCase(STRDBROWS(L, I)), "AAAAAAAAAAAAAAAAA", Chr(34) & UCase(BB) & Chr(34))
                DoEvents
            Next L
            'DoEvents
        Next I
        
        .Refresh

        SendMessage Me.hwnd, WM_SETREDRAW, SR_ON, 0&

        'Me.LNR1.Caption = ""

    End With

    If Not RSTADO Is Nothing Then
        If (RSTADO.State And adStateOpen) = adStateOpen Then
            RSTADO.Close
        End If
        Set RSTADO = Nothing
    End If

End Sub

possible to optimize the fill listview, the code is very, very slow!

note:
Records are approx 65.xxx
 
Get rid of the DoEvents. Of course you may have inserted them to make your user interface responsive. But in that case I'd reduce the number of DoEvents that you are triggering (still won't be a smooth experience). Note, however, that with ~65000 items, each with 61 subitems, populating the ListView is never going to be quick. Do you really need all the items loaded in one go?


Anyway try:

Code:
[blue]For I = 0 To UBound(STRDBROWS, 2)
            [COLOR=green]'DoEvents[/color]
            Set ITMX = .ListItems.Add(, , UCase(STRDBROWS(0, I)))
            For L = 1 To 61
                ITMX.SubItems(L) = Replace(UCase(STRDBROWS(L, I)), "AAAAAAAAAAAAAAAAA", Chr(34) & UCase(BB) & Chr(34))
                [COLOR=green]'DoEvents[/color]
            Next L
            [b]If I Mod 2000 = 0 then DoEvents[/b]
        Next I[/blue]
 
hi strongm,
in effect NO! i dont need to show all 65.xxx, rks.
BUt for example at the first time, for example load the first 1000 rks in listview, and use a button to simulate a paging(first, next last, ecc...) on the listview... for examplae with a page size 1000.
But not idea for tath:)
 
Alternatively, why not use a data aware control, and load it directly from your recordset?
 
why not use a data aware control, and load it directly from your recordset...

?????

never used

Sorry me, bro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top