Click here to Skip to main content
15,881,172 members
Articles / Programming Languages / C#
Article

Google-like PageLister control which helps to organize paging representation of your data.

Rate me:
Please Sign up or sign in to vote.
3.08/5 (12 votes)
15 Feb 20042 min read 37.4K   1.1K   15   1
Google-like PageLister control which helps to organize paging representation of your data.

Sample Image - demo.gif

Introduction

Some time ago, while I was working on one of my projects, I needed a control for paging representation of some data. When I'm talking about "paging representation", I mean representation in portions, page by page. Probably, the best example of it you can find on virtually any search machine like google, altavista etc.

What I needed is a line of clickable links representing pages filled with some information with current page highlighted. When a link is clicked, an event must be fired to allow the application to change the page.

First, I tried to find such a control somewhere in the net but my brief search wasn't successful. The requirements for the control were pretty simple so I decided that I would spend less time writing it than looking for it.

As I said, the control is pretty simple and, I hope, well commented. You surely don't need to be a genius to write something like this yourself. Here I skip most of the realization details and describe the control's interface.

Control's interface

What this control has is only three properties and one event.

The properties are:

  • uint PagesCount {get; set;} - gets or sets the total number of pages the control must present.
  • uint CurrentPage {get; set;} - gets or sets 1-based number of the current page.
  • uint NumPagesShown {get; set;} - gets or sets the number of links that can be shown on each side of the current page's link. Normally, you see current link in the centre of the links line and equal number of links (NumPagesShown) on each side. Of course, when current page is close to the beginning or to the end of line it moves from the central position. So, the maximal total number of links shown is 2*NumPagesShown + 1 or PagesCount, whatever is less.

The event PageChanged is fired when the current page is changed. The only event handler's parameter, currentPage is the new current page's number which you can also receive using CurrentPage property.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalsimple & artistically Pin
Norton19-Feb-04 15:52
Norton19-Feb-04 15:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.