Solved

Paging through a listview

Posted on 2004-04-02
16
530 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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 28

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

717 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