|
-
Oct 26th, 2002, 02:19 PM
#1
Thread Starter
Frenzied Member
Unload hanging
Hello everybody peeps.
has anyone found a way of stopping the PC hanging when you unload a form with over 20,000 rows in a listview? The more rows i have , the longer it takes to unload the app.
6000 rows is about 4 seconds, 15000 rows, about 30 seconds and 25000 rows i may as well go for a pint! Any ideas on how to speed this up?
Ta muchly
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 26th, 2002, 02:22 PM
#2
The picture isn't missing
End.............................. could work...
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Oct 26th, 2002, 03:35 PM
#3
Software Eng.
Do you have any code that processes the listview items in the unload event?
-
Oct 26th, 2002, 03:39 PM
#4
I think if you put ListView1.ListItems.Clear in the Unload event, it will speed thigs up.
-
Oct 26th, 2002, 06:19 PM
#5
Thread Starter
Frenzied Member
Guys, I already have a listview.listitems.clear in the unload and i see the rows disappear from the screen as it happens but when it hits the unload................i have to wait for about 3 minutes while it recovers. Ill just have to restrict the rows returned.....sounds sensible anyway.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 26th, 2002, 08:12 PM
#6
Just for the heck of it could you post your unload code?
-
Oct 27th, 2002, 06:06 AM
#7
Thread Starter
Frenzied Member
Sure, The Exit button does all the data unloading and i have no Unload sub. Heres the exit code:
VB Code:
Private Sub CommandExit_Click()
If CommandExit.Caption = "Exit" Then
Status = "Unloading data....please wait!"
Status.Refresh
MatchFiles.ListItems.Clear
Unload Me
Else
CancelSearch = True
End If
End Sub
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 27th, 2002, 06:48 AM
#8
PowerPoster
Here is my test: it takes fraction of a second to unload form with Listview having 20,000 items:
VB Code:
Option Explicit
Dim ITM As ListItem
Dim LSI As ListSubItem
Private Sub Form_Load()
Dim i&, j%
With ListView1.ColumnHeaders
.Add , "LI", "List Item"
For j = 1 To 3
.Add , "SI" & j, "Sub Item " & j
Next j
End With
For i = 1 To 20000
Set ITM = ListView1.ListItems.Add(, , "Listitem " & i)
For j = 1 To 3
Set LSI = ITM.ListSubItems.Add(, "Subitem" & j, "Subitem " & j)
Next j
Next
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
ListView1.ListItems.Clear
End Sub
-
Oct 27th, 2002, 10:19 AM
#9
Thread Starter
Frenzied Member
IROY55, fancy hearing from you 
Well the only difference i have in my code to you in yours is that i have 6 columns in my Listview and 28,000 rows....it takes about 1 and a half minutes to unload when i click exit. Ive moved the listitems.clear code to the query_unload event too.
No idea what up with it. I can post u the whole code if u want to try it out on your pc. Its a windows explorer substitute when its finished.....not far to go with it, just the right click menu popup and the print results key to do.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 27th, 2002, 11:33 AM
#10
Hyperactive Member
The problem is VB is doing housekeeping. You might want to change to a grid, or if you want to keep your listview, create a scrollbar to replace the listview one and store the data in your own variables/arrays.
-
Oct 27th, 2002, 12:04 PM
#11
PowerPoster
No idea what up with it. I can post u the whole code if u want to try it out on your pc
Sure, why not. Will be my pleasure.
Cheers
-
Oct 27th, 2002, 05:59 PM
#12
Thread Starter
Frenzied Member
Marnitzg, thanks for the reply, i figured as much but wondered why IROY55 could exit with similar data and it not hang his app for 3 minutes!
IROY55
Hello chap, you have emails blocked from this board so cant send.
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 27th, 2002, 09:47 PM
#13
PowerPoster
No personal emails, but why don't you post it here? Later ...
-
Oct 28th, 2002, 05:36 PM
#14
Hyperactive Member
I had the same problem some time ago when I had to do maintenance on a database program that was only supposed to have +-100 records. The company then merged with another and boom suddenly there are 350000 products. I tell you it took about 20 minutes for the prog to load and about an hour to shut down.
The time it takes to shut down is also dependent. Remember that the more columns you have, the more data is held. 20000 *3 = 60000 integers is not that much data. I'm not sure how a listview holds data but I would think it would be in variants. So if you have 20000 records of 15 character strings, thats quite a bit more data on its own, and thats only taking into account 1 column.
-
Oct 28th, 2002, 07:32 PM
#15
Thread Starter
Frenzied Member
Yep i suppose so......ill just put a n unloading message on the screen or limit the amount of rows returned i think. No point in making the user think the apps crashed :/
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 28th, 2002, 08:05 PM
#16
PowerPoster
Guys, despite Listview or perhaps Listbox may hold thousands of items, the question that comes to mind is "WHY DO YOU HAVE TO LOAD THIS MANY???". Why not considering to work with "chunks" of data whatever that could be (few hundred/thousand but definitely not 350,000 or so). Who's going to look through this many records anyway???
-
Oct 29th, 2002, 09:24 AM
#17
Thread Starter
Frenzied Member
A very good point IROY but you dont usually know how many rows you are going to retrieve from a search until the search is complete anyway and by that time you have loaded the rows into the table already. See, my app is like windows explorer and if you select a filename of * and choose all subdirectories, the app finds all files on your drive! My only option fortunately is to check the rowcount as i go and limit the amount of loaded rows to say 1000 (like the Windows explorer find option does).
There are 3 types of people in this world.........those that can count, and those that can't.
Blobby
-
Oct 29th, 2002, 10:58 AM
#18
PowerPoster
but you dont usually know how many rows you are going to retrieve from a search until the search is complete
You may create a stored proc on the server with in-parameters to limit your seach: parm will tell how many records to get. And after all it will be much faster anyway the any SQL statement you ever send.
-
Oct 29th, 2002, 11:20 AM
#19
Frenzied Member
I have to agree with IROY55: unless you are doing some form of administrative work there should be no way that your users can process/visualise or even contemplate more than about 100 records.
Make the users search - this will cut down the record count.
If you really must have this amount of records check out ADO's paging facility (it enables you to only to fetch pages based on cursor pointers)
You could also load all of the items into an array (or some such structure) and only load the listview with the items that are currently being displayed (urgghh)
I think that the design is at fault not the code - as the code looks fine to me
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
|