C # page Flip design: Home, Prev, Next, last, jump

Source: Internet
Author: User

 int pageSize = 0;         Number of rows per page int nMax = 0;    Total number of records int pagecount = 0;   Number of pages = Total Records/pages per page int pagecurrent = 0;      Current page number int ncurrent = 0;            The current record line private void Bind () {//td = Um.dataall ();      PageSize = 30; Set number of page lines NMax = TD.            Rows.Count;    PageCount = (nmax/pagesize);            Calculates the total number of pages if ((nMax% pageSize) > 0) pagecount++;    Pagecurrent = 1;       The current number of pages starts from 1 ncurrent = 0;        The current number of records starts at 0 loaddata ();   }private void LoadData () {int nstartpos = 0;     The current page starts recording line int nendpos = 0; Current page end record line DataTable dttemp = TD.   Clone ();            Clone the DataTable Structure Framework if (pagecurrent = = PageCount) {nendpos = NMax;            } else {nendpos = pageSize * pagecurrent;            } Nstartpos = Ncurrent; Lblpagecount.text = "Total" + pageCount.tostring () + "page";            Txtcurrentpage.text = convert.tostring (pagecurrent); Copy the record line from the metadata source if (TD.                    Rows.Count > 0) {for (int i = Nstartpos; i < Nendpos; i++) { Dttemp.importrow (TD.                    Rows[i]);                ncurrent++;            }} datagridview1.datasource = Dttemp; DataGridView the line int ENDC = TD is not selected by default.            Rows.Count;            if (Endc > PageSize * pagecurrent) ENDC = pageSize * pagecurrent;            int k = 0; for (int i = pageSize * (pageCurrent-1) + 1; I <= ENDC; i++) {datagridview1.rows[k].                Headercell.value = i.ToString ();            k++;            }}private void Up_click (object sender, EventArgs e) {pagecurrent--; if (pagecurrent <= 0) {MessageBox.Show ("is already the first page,Please click on "Next Page" to view!                ");            Return            } else {ncurrent = PageSize * (pageCurrent-1);        } loaddata ();            } private void Down_click (object sender, EventArgs e) {pagecurrent++; if (Pagecurrent > PageCount) {MessageBox.Show ("is already the last page, please click on" Previous "to view!)                ");            Return            } else {ncurrent = PageSize * (pageCurrent-1);        } loaddata ();            } private void First_click (object sender, EventArgs e) {pagecurrent = 1;            Ncurrent = PageSize * (pageCurrent-1);        LoadData ();            } private void End_click (object sender, EventArgs e) {pagecurrent = PageCount;            Ncurrent = PageSize * (pageCurrent-1);        LoadData (); private void Skip_click (object sender, EventArgs e) {iNT CURRENTP = Convert.ToInt32 (txtCurrentPage.Text.ToString ());                if (Currentp > PageCount) {MessageBox.Show ("more than the maximum number of pages, please reenter");            Return                } else {pagecurrent = CURRENTP;                Ncurrent = PageSize * (pageCurrent-1);            LoadData (); }        }

C # page Flip design: Home, Prev, Next, last, jump

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.