|
-
Nov 25th, 2000, 12:12 AM
#1
Thread Starter
Addicted Member
I am adding a bunch of items to the listview control.
I want to add the first 100 items or so and add the rest using a refresh or DoEvents procedure. The problem is that
the control repaints itself after each item is added. Is
there a way to shut off the repaint after the first 100 items
have been added?
Always looking for a better and faster way!
-
Nov 25th, 2000, 12:47 AM
#2
Use the LockWindowUpdate API call -
Code:
'Put this in the declarations section of a module or form
Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Then when you want to stop the refreshing, do this:
Code:
'before addign any items, call LockWindowUpdate
LockWindowUpdate ListView1.Hwnd
'Add all your items here
'Now that you've added your items, unloack the window,
'which is done by passing 0 to the API call
LockWindowUpdate 0
That does it very nicely
- gaffa
-
Nov 25th, 2000, 01:49 AM
#3
Thread Starter
Addicted Member
That works great but I want to have user control with the
items in the ListView at the same time the items are being added. I need to use some sort of DoEvents in that case.
This is what is causing the flicker. When I use the LockWindowUpdate function, there is no user intervention.
Always looking for a better and faster way!
-
Nov 27th, 2000, 11:08 AM
#4
Thread Starter
Addicted Member
I decided to make the program list different pages of
data.
I fill the listview with about 100 items per page.
I set buttons and a text box where users can move between
pages of data. This process works great!
Code:
Private Sub RetrieveItems(SQLCount as String, _
SQL as Integer, Page as Integer, Database as Connection)
Dim recData As New Recordset
Dim intItem As Integer
Dim intCount As Integer
'Gets the count of records retrieved
recData.Open SQLCount, Database
intCount = recData.intCount
If intCount > 100 Then
'Checks for a valid page
If 100 * Page <= intCount And Page > 0 Then
'Retrieves the records for that page
'Example: Page = 1 then Move to 0, intCount = 100
'Example: Page = 10 then Move to 900, intCount = 1000
intCount = 100 * Page
recData.Move 100 * (Page - 1)
Else
MsgBox "This page does not exist.", vbInformation, "Page"
EndIf
EndIf
recData.Close
'Retrieves the records
recData.Open SQL, Database
'Adds the records to the ListView
For intItem = 1 To intCount
'Add item and subitems
Next
'Destroys variable
Set recData = Nothing
End Sub
Always looking for a better and faster way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|