|
-
Nov 14th, 2000, 04:27 PM
#1
Thread Starter
Addicted Member
I have a listview that is being populated with about 6000 items...
Code:
Dim recItems As Recordset
Dim intCount As Integer
Dim intItem As Integer
Dim lstItem As ListItem
Dim lstColumn As ColumnHeaders
Dim intColumn As Integer
With dbsData
Set recItems = .QueryDefs("Debtor Count").OpenRecordset
intCount = recItems!Count
set recItems = .QueryDefs("Debtor List").OpenRecordset
End With
For intItem = 1 To intCount
'Adds the item to the list
Set lstItem = frmForm.vewitems.ListItems.Add()
With lstItem
.SmallIcon = CInt(recItems!Image)
.Icon = CInt(recItems!Image) - 2
.Key = recItems!Id
.Text = recItems!Name
'Adds the subitems
Set lstColumn = frmForm.vewitems.ColumnHeaders
For intColumn = 2 To lstColumn.Count
.SubItems(intColumn - 1) = "" & _
recItems.Fields (lstColumn(intColumn).Key)
Next
.Ghosted = recItems!Deleted
End With
recItems.MoveNext 'Next record
Next
This takes a few seconds. I found a way to make it faster. I want to add only the first visible items to the listview and add blank items for the rest. As I scroll the listview, I want to be able to add the details for the blank items.
The problem is, there is no scroll event for the listview. Does anyone know how to execute code when someone scrolls the listview?
Always looking for a better and faster way!
-
Nov 15th, 2000, 09:40 AM
#2
Frenzied Member
I dunno about the listview scrolling event, but if you
want it faster, try this :
Code:
Dim anyArray
With dbsData
Set recItems = .QueryDefs("Debtor Count").OpenRecordset
intCount = recItems!Count
set recItems = .QueryDefs("Debtor List").OpenRecordset
End With
anyArray = recItems.GetRows
that way your connection will be close right away and
you wont have to work with recorset, just with an array.
And instead of intCount you can use:
Code:
For intItem = 1 To Ubound(anyArray,2)
let me know if you try it, and the result!!!
-
Nov 15th, 2000, 09:51 AM
#3
Fanatic Member
for the scrolling.....
Code:
'paste this into a form with 1 command button and 1 listview
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LVM_FIRST = &H1000 '// ListView messages
Private Const LVM_SCROLL = (LVM_FIRST + 20)
Private Sub Command1_Click()
Dim HorizPixels, VertPixels As Long
HorizPixels = 0
VertPixels = 30
SendMessage ListView1.hwnd, LVM_SCROLL, ByVal HorizPixels, ByVal VertPixels
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 100
ListView1.ListItems.Add , , "ListItem" & i
Next i
End Sub
hth
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Nov 15th, 2000, 01:35 PM
#4
Thread Starter
Addicted Member
That idea with the array works great. The problem is that
I am changing the columnheaders in the listview control
depending on what option is clicked. For that reason, I
use a Key to access a column and i use the same Key in the
field of the recordset...
Code:
ListView.ListItems.SubItems("Key") = Recordset.Fields("Key")
I cant access with the index...yet. I am still working on
a way to do that.
I am going to try to use the scrolling code given also.
Thanks
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
|