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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

very slow to create at run time listview

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
422
IT
Code:
Private Sub CREA_LVORARI()

    Dim DA As Date, A As Date
    Dim D As Date

    DA = "07:00"
    A = "21:30"

    With Me.LVORARI

        LockWindowUpdate Me.hwnd

        .ColumnHeaders.Clear
        .ColumnHeaders.Add , , "TAVOLO", 2000
        .ColumnHeaders.Add , , "DATA", 1000, lvwColumnCenter

        For D = DA To A + 0.000001 Step TimeSerial(0, 30, 0)
            .ColumnHeaders.Add , , Format$(D, "HH:MM"), 600, lvwColumnCenter
        Next D

        For K = 0 To UBound(STRDBROWS_TAVOLI, 2)
            TAVOLO = STRDBROWS_TAVOLI(2, K) & "-" & "TAVOLO-POSTI: " & STRDBROWS_TAVOLI(1, K)
            Set ITMX = .ListItems.Add(, , TAVOLO)
        Next K

        LockWindowUpdate 0&

    End With

End Sub

i call:

Private Sub Form_Initialize()
call CREA_LVORARI
End Sub

note:
STRDBROWS_TAVOLI is an array variant from getrow of recorset
Me.LVORARI is the listview
the array have only 23 element!
 
How big is the array - and how are you determining that it is "very slow"?
 
the array have only 23 element!

20 SECS approx
 
Ok, then there is something else going on in your code. If we just use the code you present here (and with an artificial STRDBROWS_TAVOLI array) then the LV populates pretty much instantaneously. Have you, for example, got any events for the ListView?
 
wath type of event, for example?
 
Er ... it's your code, you should be able to see if you have any events defined. I'm not going to randomly guess.

And let's also be clear - I am speculating; a control event might be the cause of the slowdown. But there may be other causes. Without seeing your code there's no way right now to determine what is actually causing the slowdown. It might, for example, be linked to the Sorted property (although I doubt it). Or anything, We can't know from the code you have posted here so far.
 
>BeginUpdate and EndUpdate

That's for the .Net listview control. This forum is for classic VB (VB5/6), and its somewhat less functional listview control
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top