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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.