Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi! I'm in a programming class learning C#. For our final one of our directions says, "You should code a mechanism that displays 20 lines (of our data) at a time on the list view and then the user must request somehow the next 20 records to be displayed" I've looked around and I can't figure out to do it.

What I have tried:

I know how to display all the data I want in the list view, I just can't figure out how to display only 20 lines of it, and then have something (most likely a button since we use Visual Studios) to display the next 20 lines after the first 20.
Posted
Updated 17-Apr-23 11:58am
v2
Comments
George Swan 18-Apr-23 3:37am    
Have you tried searching for: C# List paging?
PIEBALDconsult 18-Apr-23 14:38pm    
If you are using a DataTable as the backing store, it should be simple.

1 solution

You'll have to implement your own layer for "paging" the data. Basically, you'll be adding code to divide up the data into "pages". You'll have to keep track of the page size (how many records are in a page) and the requested page number. The "pages" don't really exist. They are just mathematical concepts that describe how many records to skip in the data and how many to return.

The "Next" button will just request the next page number with a specified page size. You'll have to bind the listview to the data page being returned to get it to display.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900