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

Listview control

Status
Not open for further replies.

btaber

Programmer
May 26, 2002
307
US
I am using a listview control to display a DB recordset, but I have found that a large resultset causes the listview to take a long time to load. Is there a better method to load the listview to speed things up?

B
 
Are you adding items to a standard Listview control? Have you tried the bound Listview control - DataList? I haven't used it but it may help.

If you can't use a bound control try ...

1) Set the control's .Visible property to false so it won't try to update it's display after every item is added. Show it after everything is added.

2) Investigate using API function to populate it - SendMessage() and LVM_* messages.


Net_Giant

What fun is a technology if you can't crash the OS?
 
I'm using DAO, so I can't use the bound control, and setting the isible property did not help.. any other thoughts?
 
How many items are you adding to the listview?


Net_Giant

What fun is a technology if you can't crash the OS?
 
the code looks like this:
Code:
    Set rs = db.OpenRecordset("SELECT * FROM Customers ORDER BY Alias", dbOpenDynaset, dbReadOnly)

    Do Until rs.EOF
        myitems.Add , , rs.Fields("ID")
        If Not IsNull(rs.Fields("Alias")) Then
            myitems(myitems.Count).ListSubItems.Add , , rs.Fields("Alias")
        Else
            myitems(myitems.Count).ListSubItems.Add , , ""
        End If
        If Not IsNull(rs.Fields("Name")) Then
            myitems(myitems.Count).ListSubItems.Add , , rs.Fields("Name")
        Else
            myitems(myitems.Count).ListSubItems.Add , , ""
        End If
        If Not IsNull(rs.Fields("Address")) And Not IsNull(rs.Fields("City")) Then
            myitems(myitems.Count).ListSubItems.Add , , rs.Fields("Address") & ", " & rs.Fields("City")
        Else
            myitems(myitems.Count).ListSubItems.Add , , ""
        End If
        rs.MoveNext
    Loop

that iterates through about 10,000 records
Hope that explains it.
 
btaber,

What value in the adding 10,000 records to the listview? Consider adding them set by set while scrolling the control.
Justify number of records in the set.

Vladk
 
That is what I would love to do, but how would I go about doing that?

B
 
btaber,

The better way is probably to redesign the query and the GUI accordingly. So many records at a time could indicate poor business requirements.

Vladk
 
btaber,

If you cannot change requirements, look at the page of our forum. It has 1,2,3,... next buttons. You cad add "next" and "back" buttons and repopulate your listview based on the query that would return specified recordset dynamically.

Vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top