Solved

Paging through a listview

Posted on 2004-04-02
16
478 Views
Last Modified: 2008-01-16
I have a listview that can potentially return 50,000 items.

I want to return only a portion of the records at one time to the user(500?) in the listview so they can scroll down to the bottom of the list.

When the user gets near the bottom of the list, the records need to add in the next 500 so the user can continue to scroll beyond the initial list of 500 all the way to the end of the list.  

Is this possible?

What solutions do others use to scroll a large list of items.

I already know some responses will be to just allow the users to scroll a filtered list, but this is not always ideal.

Users want to scroll to any item in the list...
0
Comment
Question by:tmorita
  • 5
  • 3
  • 2
  • +4
16 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10745393
What solutions do others use to scroll a large list of items.

It seems that your trying to optimize your code, in this case best method is to load next
500 data when user tries to show item 501.

This depends how many rows fit in the listview.

Is your listview resizable or no , it if a fix size?
0
 
LVL 27

Expert Comment

by:Dabas
ID: 10745449
Hi tmorita:
> What solutions do others use to scroll a large list of items.
>
> I already know some responses will be to just allow the users to scroll a
> filtered list, but this is not always ideal.
>
> Users want to scroll to any item in the list...

Looks like a contradiciton to me.

If somebody presents me with a list of 50,000 items, shows me the first 500, and I scroll down, but know I am interested in an item that is more than half way down, then I do not think that I will want to scroll to any item in the list without having a filter in place.

SQL Server Enterprise Manager works in a similar way to what you want to achieve.
When the list is very big, it is very frustrating.. you keep scrolling down, but your record is still further on.

I would suggest you reconsider, and allow the user to enter any partial text. Then filter it with a Like statement to either show only items starting with the partial text, or items that include the partial text.

Dabas
0
 

Author Comment

by:tmorita
ID: 10745512

unknown_routine

>It seems that your trying to optimize your code, in this case best method is to load next
>500 data when user tries to show item 501.

The listview will fit as many records as needed in a fixed viewable area that only shows about 25 records.

I am working with VB6 and SQl 2000 and I cant seem to find a good way to get the next 500 rows when the user scrolls down.
0
 

Author Comment

by:tmorita
ID: 10745517
Dabas

We already have functionality in place that will allow users to find an item in the displayed records using the finditem function.  
This will not work if someone has returned a partial list and wants to search for an item outside that list.

0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10745561
Hi again:

The only way i can think of is to combine a timer control and use GetFirstVisible
property.

GetFirstVisible returns a Listitem which is top and visible. know that you got 25 records  you tell
you when it is the time to load next 500 records.

so when GetFirstVisible retuns item 475 it is time to load next 500 items and so on.


0
 

Author Comment

by:tmorita
ID: 10745620
>GetFirstVisible returns a Listitem which is top and visible. know that you got 25 records  you tell
>you when it is the time to load next 500 records.

If users are using the scroll bar - how can I tell when they have scrolled to the bottom of the list?
I can do this when users page up or down or use the arrow keys, but I have not found a way to tell if the user has scrolled to the bottom.
0
 
LVL 6

Expert Comment

by:___XXX_X_XXX___
ID: 10745703
Or you can create list view with fixed number of list items (for example 50 rows) and provide user with buttons "Next","Next 50" and "Next 500". In this manner your list view will not have it's vertical scroll bar and you will change the text in existing (loaded in Form_Load) list items. Your list view will contain only 50 rows and will not use memory for 50000 rows.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Expert Comment

by:___XXX_X_XXX___
ID: 10745715
Or provide user with your vertical scroll bar (not default provided by list view).
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10745752
Take a look at this article:  http://vbnet.mvps.org/index.html?code/subclass/lvscrollbars.htm

It describes subclassing the ListView control and using a Windows API function to get scroll info.  I haven't tried it out so I can't definitively say it'll solve your problem.  My thought is that if you can get scrolling information, then you can tell where the ListView is positioned.  If that's possible, then it should be a simple matter to write some code that detects when the ListView is near the bottom and loads the next batch of records.  
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10745804

Thats  why i suggested to use a timer to track the scroll of the list box:
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10745813
If users are using the scroll bar - how can I tell when they have scrolled to the bottom of the list?
================

Thats  why i suggested to use a timer to track the scroll of the list box:(GetFirstVisible)

you can track the top Item every .2 or oven .1 second without  any perfirmance hit.

0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 10745818
Sorry for the typo's,

its Sat night, lol

you can track the top Item every .2 or even .1 second without  any performance hit!


0
 
LVL 27

Expert Comment

by:Ark
ID: 10755565
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11441120
PAQed - no points refunded (of 500)

modulo
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now