C ා devexpress gridcontrol paging control control production

Posted by nomis on Sun, 26 Jan 2020 18:42:25 +0100

The implementation of this small function is a little complicated. Paging is controlled by a single user control, which results in the separation of query paging and gridcontrol pages. Generally, girdcontrol is notified to query through paging events

Sometimes query all, sometimes a month, or some other time. Do the corresponding assignment on the control in the paging control. Think about the complexity of implementation

If the amount of data is large enough: the first step is to find out the total amount of data first, initialize the number of pages on the page, the number of pages and the current page according to the total amount, assign the data on the first page to gridcontrol first through database query, and assign the data on the other pages when the user clicks

Total query data:

 

  /// <summary>
        ///Number of query records
        /// </summary>
        ///< returns > number of records < / returns >
        public int Count()
        {
            const string sql = "SELECT count(*) as id FROM [dbo].[Contacts]";
            using (SqlConnection connection = new SqlConnection(connstr))
            {
                int list = Convert.ToInt32(connection.ExecuteScalar(sql));
                return list;
            }

        }

 

Database query page code:

 

   /// <summary>
        //Paging
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public IEnumerable<Model.ScanAllData> Page(int pageIndex, int pageSize)
        {
            const string sql = @"select * from(select *,(ROW_NUMBER() over(order by id asc))as newId from Contacts) as t 
                                 where t.newId between (@pageIndex-1)*@pageSize+1 and  @pageSize*@pageIndex";
            using (SqlConnection connection = new SqlConnection(connstr))
            {
                var reader = connection.Query<Model.ScanAllData>(sql, new { pageIndex = pageIndex, pageSize = pageSize });
                return reader;
            }

        }

 

Pagination control style chart

Create a new user control, add panel container, and then from left to right, you need button, input box, drop-down box, and then drag labelcontrol one by one

The code is as follows:

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//MGNC
//QQ:1981633
namespace WORKALERT
{
    public partial class MgncPager : UserControl
    {
        private int allCount = 0;
        private int pageSize = 10;
        private int curPage = 1;
        public delegate void MyPagerEvents(int curPage,int pageSize);
        public delegate void ExportEvents(bool singlePage);//Single page, all
        public event MyPagerEvents myPagerEvents;
        public event ExportEvents exportEvents;
        public MgncPager()
        {
            InitializeComponent();
        }
        //Calculate paging, paging size, total number of records.
        public void RefreshPager(int pageSize,int allCount,int curPage)
        {
            this.allCount = allCount;
            this.pageSize = pageSize;
            this.curPage = curPage;
            this.textEditAllPageCount.Text = GetPageCount().ToString();
            lcStatus.Text = string.Format("(common{0}Records, per page{1}A total of{2}page)", allCount, pageSize, GetPageCount());
            textEditCurPage.Text = curPage.ToString() ;
            textEditToPage.Text = curPage.ToString();
            comboBoxEditPageSize.Text = pageSize.ToString();

            if (curPage == 0)
            {
                if (GetPageCount() > 0)
                {
                    curPage = 1;
                    myPagerEvents(curPage, pageSize);
                }
            }
            if (curPage > GetPageCount())
            {
                curPage = GetPageCount();
                myPagerEvents(curPage, pageSize);
            }
            
        }
        //Get total records
        public int GetAllCount()
        {
            return allCount;
        }
        //Get the current page number, starting with 1
        public int GetCurPage()
        {
            return curPage;
        }
        //Get total pages
        public int GetPageCount()
        {
            int count = 0;
            if (allCount % pageSize == 0)
            {
                count = allCount / pageSize;
            }
            else
                count = allCount / pageSize+1;
            return count;
        }

        private void simpleButtonNext_Click(object sender, EventArgs e)
        {
            if (myPagerEvents != null)
            {
                if(curPage<GetPageCount())
                curPage += 1;
                myPagerEvents(curPage,pageSize);
            }
        }

        private void simpleButtonEnd_Click(object sender, EventArgs e)
        {
            if (myPagerEvents != null)
            {
                
                curPage = GetPageCount();
                myPagerEvents(curPage, pageSize);
            }
        }

        private void simpleButtonPre_Click(object sender, EventArgs e)
        {
            if (myPagerEvents != null)
            {
                if (curPage > 1)
                    curPage -= 1;
                myPagerEvents(curPage, pageSize);
            }
        }

        private void simpleButtonFirst_Click(object sender, EventArgs e)
        {
            if (myPagerEvents != null)
            {

                curPage = 1;
                myPagerEvents(curPage, pageSize);
            }
        }

        

        private void simpleButtonToPage_Click(object sender, EventArgs e)
        {
            try
            {
                int selPage = Convert.ToInt32(textEditToPage.Text);
                if (myPagerEvents != null)
                {
                    if ((selPage >= 1) && (selPage <= GetPageCount()))
                        curPage = selPage;
                    myPagerEvents(curPage, pageSize);
                }
            }
            catch (Exception)
            {
                
                //throw;
            }

        }

        private void simpleButtonExportCurPage_Click(object sender, EventArgs e)
        {
            try
            {
                if (exportEvents != null)
                {
                    exportEvents(true);
                }
            }
            catch (Exception)
            {

                //throw;
            }
        }

        private void simpleButtonExportAllPage_Click(object sender, EventArgs e)
        {
            try
            {
                if (exportEvents != null)
                {
                    exportEvents(false);
                }
            }
            catch (Exception)
            {

                //throw;
            }
        }

        private void comboBoxEditPageSize_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                int pageSize = Convert.ToInt32(comboBoxEditPageSize.Text);
                if ((pageSize > 0))
                {
                    this.pageSize = pageSize;
                    myPagerEvents(curPage, pageSize);
                }

            }
            catch (Exception)
            {

            }
        }
    }
}

 

Call:

Add two events:

    mgncPager1.myPagerEvents += MyPagerEvents; //new MgncPager.MyPagerEvents(MyPagerEvents);
            mgncPager1.exportEvents += ExportEvents;// new MgncPager.ExportEvents(ExportEvents);

 

   public int curPage = 1;
        public int pageSize = 10;
        public int allcount = 0;
  public void ExportEvents(bool singlePage)//Single page, all      
        {
            //The export GridControl code is written here.
        }
        public void RefreshGridList()
        {
            FillGridListCtrlQuery(curPage);//Implement the FillGridListCtrlQuery function by yourself.      
        }

        private void FillGridListCtrlQuery(int curPage = 1)   //Update controls
        {
       //  GridControl1.DataSource = WebService.Pager(. . . . .  //Show paging results
        mgncPager1.RefreshPager(pageSize, allcount, curPage);//Update paging control display.
        }
        private void MyPagerEvents(int curPage, int pageSize)
        {
            this.curPage = curPage;
            this.pageSize = pageSize;
            FillGridListCtrlQuery(curPage);

        }

 

Mgncpager1. Refreshpager (PageSize, allcount, curlpage); / / update the page control display.  

Each time a large amount of query data needs to be paged, the value on this control needs to be initialized

Data saving has not been realized on this side. You can borrow your article in the authenticated blog, and there is the operation code on the next page, including content export

 

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Data.SqlClient;  
using System.Drawing;  
using System.Text;  
using System.Linq;  
using System.Threading.Tasks;  
using System.Windows.Forms;  
using DevExpress.XtraEditors;  
using DZAMS.DBUtility;  
  
namespace DZAMS.Demo  
{  
  
    public partial class GridPage_Frm : DevExpress.XtraEditors.XtraForm  
    {  
        public DataTable dt = new DataTable();  
        StoreProcedure sp;  
        private int pageSize = 10;     //Lines per page  
        private int nMax = 0;         //Total number of records  
        private int pageCount = 0;    //Pages = total records / lines per page  
        private int pageCurrent = 0;   //Current page number  
        private DataSet ds = new DataSet();  
        private DataTable dtInfo = new DataTable();  
        public GridPage_Frm()  
        {  
            InitializeComponent();  
        }  
  
        private void GridPage_Frm_Load(object sender, EventArgs e)  
        {  
            string strQuery = string.Format("SELECT   Id, UserCode, UserName, RoleName, Ip, Mac, LoginTime FROM   DZ_LoginLog");  
            dt = SqlHelper.ExecuteDataset(SqlHelper.conn, CommandType.Text, strQuery.ToString()).Tables[0];  
  
            gridControl1.DataSource = dt;  
  
            string strConn = "SERVER=(local);DATABASE=DZ;UID=sa;PWD=XXXX";   //Database connection string  
            SqlConnection conn = new SqlConnection(strConn);  
            conn.Open();  
            string strSql = "SELECT count(*) as num FROM DZ_LoginLog";  
            SqlDataAdapter sda = new SqlDataAdapter(strSql, conn);  
            sda.Fill(ds, "ds");  
            conn.Close();  
  
            nMax = Convert.ToInt32(ds.Tables[0].Rows[0]["num"].ToString());  
            lblTotalCount.Text = nMax.ToString();  
            lblPageSize.Text = pageSize.ToString();  
  
            sp = new StoreProcedure("Pr_Monitor_Pagination", strConn);  
            dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent++, pageSize);  
            InitDataSet();  
  
        }  
        private void InitDataSet()  
        {  
            pageCount = (nMax / pageSize);    //Calculate the total number of pages  
  
            if ((nMax % pageSize) > 0) pageCount++;  
  
            pageCurrent = 1;    //The current number of pages starts from 1  
  
            LoadData();  
        }  
  
        private void LoadData()  
        {  
            lblPageCount.Text = "/"+pageCount.ToString();  
            txtCurrentPage.Text = Convert.ToString(pageCurrent);  
  
            this.bdsInfo.DataSource = dtInfo;  
            this.bdnInfo.BindingSource = bdsInfo;  
            this.gridControl1.DataSource = bdsInfo;  
        }  
  
        private void bdnInfo_ItemClicked(object sender, ToolStripItemClickedEventArgs e)  
        {  
            if (e.ClickedItem.Text == "Export current page")  
            {  
                SaveFileDialog saveFileDialog = new SaveFileDialog();  
                saveFileDialog.Title = "export Excel";  
                saveFileDialog.Filter = "Excel file(*.xls)|*.xls";  
                DialogResult dialogResult = saveFileDialog.ShowDialog(this);  
                if (dialogResult == DialogResult.OK)  
                {  
                    DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();  
                    gridControl1.ExportToXls(saveFileDialog.FileName, options);    
                    // gridControl1.ExportToExcelOld(saveFileDialog.FileName);  
                    DevExpress.XtraEditors.XtraMessageBox.Show("Saved successfully!", "Tips", MessageBoxButtons.OK, MessageBoxIcon.Information);  
                }    
            }  
                if (e.ClickedItem.Text == "Close")  
                {  
                    this.Close();  
                }  
                if (e.ClickedItem.Text == "home page")  
                {  
                    pageCurrent--;  
                    if (pageCurrent <= 0)  
                    {  
                        MessageBox.Show("It is already the home page. Please click "next page" to view!");  
                        return;  
                    }  
                    else  
                    {  
                        pageCurrent = 1;  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "Previous page")  
                {  
                    pageCurrent--;  
                    if (pageCurrent <= 0)  
                    {  
                        MessageBox.Show("It is the first page, please click "next page" to view!");  
                        return;  
                    }  
                    else  
                    {  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "next page")  
                {  
                    pageCurrent++;  
                    if (pageCurrent > pageCount)  
                    {  
                        MessageBox.Show("It is the last page, please click "previous page" to view!");  
                        return;  
                    }  
                    else  
                    {  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "Tail page")  
                {  
                    pageCurrent++;  
                    if (pageCurrent > pageCount)  
                    {  
                        MessageBox.Show("It is the last page, please click "previous page" to view!");  
                        return;  
                    }  
                    else  
                    {  
                        pageCurrent = pageCount;  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCount, pageSize);  
                    }  
                }  
                LoadData();  
        }  
       
    }  
}  

 

 

Attached control MgncPager.Designer.cs

 

namespace WORKALERT
{
    partial class MgncPager
    {
        /// <summary> 
        ///Required designer variables.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        ///Clean up all resources in use.
        /// </summary>
        ///< param name = "disposing" > true if managed resources should be released; otherwise, false. </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #Code generated by region component designer

        /// <summary> 
        ///Methods required for designer support - do not
        ///Use the code editor to modify the contents of this method.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MgncPager));
            this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
            this.lcStatus = new DevExpress.XtraEditors.LabelControl();
            this.simpleButtonToPage = new DevExpress.XtraEditors.SimpleButton();
            this.textEditToPage = new DevExpress.XtraEditors.TextEdit();
            this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
            this.simpleButtonExportCurPage = new DevExpress.XtraEditors.SimpleButton();
            this.simpleButtonExportAllPage = new DevExpress.XtraEditors.SimpleButton();
            this.textEditAllPageCount = new DevExpress.XtraEditors.TextEdit();
            this.labelControl4 = new DevExpress.XtraEditors.LabelControl();
            this.comboBoxEditPageSize = new DevExpress.XtraEditors.ComboBoxEdit();
            this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
            this.simpleButtonEnd = new DevExpress.XtraEditors.SimpleButton();
            this.simpleButtonNext = new DevExpress.XtraEditors.SimpleButton();
            this.textEditCurPage = new DevExpress.XtraEditors.TextEdit();
            this.simpleButtonPre = new DevExpress.XtraEditors.SimpleButton();
            this.simpleButtonFirst = new DevExpress.XtraEditors.SimpleButton();
            ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
            this.panelControl1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.textEditToPage.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEditAllPageCount.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.comboBoxEditPageSize.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEditCurPage.Properties)).BeginInit();
            this.SuspendLayout();
            // 
            // panelControl1
            // 
            this.panelControl1.Appearance.BackColor = System.Drawing.Color.White;
            this.panelControl1.Appearance.Options.UseBackColor = true;
            this.panelControl1.Controls.Add(this.lcStatus);
            this.panelControl1.Controls.Add(this.simpleButtonToPage);
            this.panelControl1.Controls.Add(this.textEditToPage);
            this.panelControl1.Controls.Add(this.labelControl2);
            this.panelControl1.Controls.Add(this.simpleButtonExportCurPage);
            this.panelControl1.Controls.Add(this.simpleButtonExportAllPage);
            this.panelControl1.Controls.Add(this.textEditAllPageCount);
            this.panelControl1.Controls.Add(this.labelControl4);
            this.panelControl1.Controls.Add(this.comboBoxEditPageSize);
            this.panelControl1.Controls.Add(this.labelControl1);
            this.panelControl1.Controls.Add(this.simpleButtonEnd);
            this.panelControl1.Controls.Add(this.simpleButtonNext);
            this.panelControl1.Controls.Add(this.textEditCurPage);
            this.panelControl1.Controls.Add(this.simpleButtonPre);
            this.panelControl1.Controls.Add(this.simpleButtonFirst);
            this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panelControl1.Location = new System.Drawing.Point(0, 0);
            this.panelControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.panelControl1.Name = "panelControl1";
            this.panelControl1.Size = new System.Drawing.Size(1089, 41);
            this.panelControl1.TabIndex = 29;
            // 
            // lcStatus
            // 
            this.lcStatus.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
            this.lcStatus.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lcStatus.Location = new System.Drawing.Point(577, 2);
            this.lcStatus.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.lcStatus.Name = "lcStatus";
            this.lcStatus.Padding = new System.Windows.Forms.Padding(13, 0, 0, 0);
            this.lcStatus.Size = new System.Drawing.Size(310, 37);
            this.lcStatus.TabIndex = 12;
            this.lcStatus.Text = "(common XXX Records, per page XX A total of XX page)";
            // 
            // simpleButtonToPage
            // 
            this.simpleButtonToPage.Dock = System.Windows.Forms.DockStyle.Left;
            this.simpleButtonToPage.Location = new System.Drawing.Point(534, 2);
            this.simpleButtonToPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonToPage.Name = "simpleButtonToPage";
            this.simpleButtonToPage.Size = new System.Drawing.Size(43, 37);
            this.simpleButtonToPage.TabIndex = 13;
            this.simpleButtonToPage.Text = "Jump";
            this.simpleButtonToPage.Click += new System.EventHandler(this.simpleButtonToPage_Click);
            // 
            // textEditToPage
            // 
            this.textEditToPage.Dock = System.Windows.Forms.DockStyle.Left;
            this.textEditToPage.EditValue = "1";
            this.textEditToPage.Location = new System.Drawing.Point(494, 2);
            this.textEditToPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.textEditToPage.Name = "textEditToPage";
            this.textEditToPage.Properties.Appearance.Options.UseTextOptions = true;
            this.textEditToPage.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.textEditToPage.Properties.AutoHeight = false;
            this.textEditToPage.Size = new System.Drawing.Size(40, 37);
            this.textEditToPage.TabIndex = 9;
            // 
            // labelControl2
            // 
            this.labelControl2.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
            this.labelControl2.Dock = System.Windows.Forms.DockStyle.Left;
            this.labelControl2.Location = new System.Drawing.Point(441, 2);
            this.labelControl2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new System.Drawing.Size(53, 37);
            this.labelControl2.TabIndex = 10;
            this.labelControl2.Text = "Current page:";
            // 
            // simpleButtonExportCurPage
            // 
            this.simpleButtonExportCurPage.Dock = System.Windows.Forms.DockStyle.Right;
            this.simpleButtonExportCurPage.Location = new System.Drawing.Point(887, 2);
            this.simpleButtonExportCurPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonExportCurPage.Name = "simpleButtonExportCurPage";
            this.simpleButtonExportCurPage.Size = new System.Drawing.Size(100, 37);
            this.simpleButtonExportCurPage.TabIndex = 2;
            this.simpleButtonExportCurPage.Text = "Export current page";
            this.simpleButtonExportCurPage.Click += new System.EventHandler(this.simpleButtonExportCurPage_Click);
            // 
            // simpleButtonExportAllPage
            // 
            this.simpleButtonExportAllPage.Dock = System.Windows.Forms.DockStyle.Right;
            this.simpleButtonExportAllPage.Location = new System.Drawing.Point(987, 2);
            this.simpleButtonExportAllPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonExportAllPage.Name = "simpleButtonExportAllPage";
            this.simpleButtonExportAllPage.Size = new System.Drawing.Size(100, 37);
            this.simpleButtonExportAllPage.TabIndex = 2;
            this.simpleButtonExportAllPage.Text = "Export all pages";
            this.simpleButtonExportAllPage.Click += new System.EventHandler(this.simpleButtonExportAllPage_Click);
            // 
            // textEditAllPageCount
            // 
            this.textEditAllPageCount.Dock = System.Windows.Forms.DockStyle.Left;
            this.textEditAllPageCount.Location = new System.Drawing.Point(402, 2);
            this.textEditAllPageCount.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.textEditAllPageCount.Name = "textEditAllPageCount";
            this.textEditAllPageCount.Properties.Appearance.ForeColor = System.Drawing.Color.Red;
            this.textEditAllPageCount.Properties.Appearance.Options.UseForeColor = true;
            this.textEditAllPageCount.Properties.AutoHeight = false;
            this.textEditAllPageCount.Properties.ReadOnly = true;
            this.textEditAllPageCount.Size = new System.Drawing.Size(39, 37);
            this.textEditAllPageCount.TabIndex = 14;
            // 
            // labelControl4
            // 
            this.labelControl4.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
            this.labelControl4.Dock = System.Windows.Forms.DockStyle.Left;
            this.labelControl4.Location = new System.Drawing.Point(346, 2);
            this.labelControl4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new System.Drawing.Size(56, 37);
            this.labelControl4.TabIndex = 15;
            this.labelControl4.Text = "Total pages:";
            // 
            // comboBoxEditPageSize
            // 
            this.comboBoxEditPageSize.Dock = System.Windows.Forms.DockStyle.Left;
            this.comboBoxEditPageSize.EditValue = "100";
            this.comboBoxEditPageSize.Location = new System.Drawing.Point(281, 2);
            this.comboBoxEditPageSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.comboBoxEditPageSize.Name = "comboBoxEditPageSize";
            this.comboBoxEditPageSize.Properties.Appearance.Options.UseTextOptions = true;
            this.comboBoxEditPageSize.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.comboBoxEditPageSize.Properties.AutoHeight = false;
            this.comboBoxEditPageSize.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
            this.comboBoxEditPageSize.Properties.DisplayFormat.FormatString = "d";
            this.comboBoxEditPageSize.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.comboBoxEditPageSize.Properties.EditFormat.FormatString = "d";
            this.comboBoxEditPageSize.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            this.comboBoxEditPageSize.Properties.EditValueChangedDelay = 1;
            this.comboBoxEditPageSize.Properties.Items.AddRange(new object[] {
            "5",
            "10",
            "15",
            "30",
            "50",
            "100"});
            this.comboBoxEditPageSize.Size = new System.Drawing.Size(65, 37);
            this.comboBoxEditPageSize.TabIndex = 7;
            this.comboBoxEditPageSize.EditValueChanged += new System.EventHandler(this.comboBoxEditPageSize_EditValueChanged);
            // 
            // labelControl1
            // 
            this.labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
            this.labelControl1.Dock = System.Windows.Forms.DockStyle.Left;
            this.labelControl1.Location = new System.Drawing.Point(201, 2);
            this.labelControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new System.Drawing.Size(80, 37);
            this.labelControl1.TabIndex = 8;
            this.labelControl1.Text = " Page size:";
            // 
            // simpleButtonEnd
            // 
            this.simpleButtonEnd.Appearance.Options.UseTextOptions = true;
            this.simpleButtonEnd.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.simpleButtonEnd.Dock = System.Windows.Forms.DockStyle.Left;
            this.simpleButtonEnd.Image = ((System.Drawing.Image)(resources.GetObject("simpleButtonEnd.Image")));
            this.simpleButtonEnd.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
            this.simpleButtonEnd.Location = new System.Drawing.Point(162, 2);
            this.simpleButtonEnd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonEnd.Name = "simpleButtonEnd";
            this.simpleButtonEnd.Size = new System.Drawing.Size(39, 37);
            this.simpleButtonEnd.TabIndex = 0;
            this.simpleButtonEnd.Click += new System.EventHandler(this.simpleButtonEnd_Click);
            // 
            // simpleButtonNext
            // 
            this.simpleButtonNext.Appearance.Options.UseTextOptions = true;
            this.simpleButtonNext.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.simpleButtonNext.Dock = System.Windows.Forms.DockStyle.Left;
            this.simpleButtonNext.Image = ((System.Drawing.Image)(resources.GetObject("simpleButtonNext.Image")));
            this.simpleButtonNext.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
            this.simpleButtonNext.Location = new System.Drawing.Point(123, 2);
            this.simpleButtonNext.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonNext.Name = "simpleButtonNext";
            this.simpleButtonNext.Size = new System.Drawing.Size(39, 37);
            this.simpleButtonNext.TabIndex = 0;
            this.simpleButtonNext.Click += new System.EventHandler(this.simpleButtonNext_Click);
            // 
            // textEditCurPage
            // 
            this.textEditCurPage.Dock = System.Windows.Forms.DockStyle.Left;
            this.textEditCurPage.EditValue = "1";
            this.textEditCurPage.Location = new System.Drawing.Point(80, 2);
            this.textEditCurPage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.textEditCurPage.Name = "textEditCurPage";
            this.textEditCurPage.Properties.Appearance.Options.UseTextOptions = true;
            this.textEditCurPage.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.textEditCurPage.Properties.AutoHeight = false;
            this.textEditCurPage.Properties.ReadOnly = true;
            this.textEditCurPage.Size = new System.Drawing.Size(43, 37);
            this.textEditCurPage.TabIndex = 4;
            // 
            // simpleButtonPre
            // 
            this.simpleButtonPre.Appearance.Options.UseTextOptions = true;
            this.simpleButtonPre.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.simpleButtonPre.Dock = System.Windows.Forms.DockStyle.Left;
            this.simpleButtonPre.Image = ((System.Drawing.Image)(resources.GetObject("simpleButtonPre.Image")));
            this.simpleButtonPre.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
            this.simpleButtonPre.Location = new System.Drawing.Point(41, 2);
            this.simpleButtonPre.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonPre.Name = "simpleButtonPre";
            this.simpleButtonPre.Size = new System.Drawing.Size(39, 37);
            this.simpleButtonPre.TabIndex = 0;
            this.simpleButtonPre.Click += new System.EventHandler(this.simpleButtonPre_Click);
            // 
            // simpleButtonFirst
            // 
            this.simpleButtonFirst.Appearance.Options.UseTextOptions = true;
            this.simpleButtonFirst.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            this.simpleButtonFirst.Dock = System.Windows.Forms.DockStyle.Left;
            this.simpleButtonFirst.Image = ((System.Drawing.Image)(resources.GetObject("simpleButtonFirst.Image")));
            this.simpleButtonFirst.ImageLocation = DevExpress.XtraEditors.ImageLocation.MiddleCenter;
            this.simpleButtonFirst.Location = new System.Drawing.Point(2, 2);
            this.simpleButtonFirst.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.simpleButtonFirst.Name = "simpleButtonFirst";
            this.simpleButtonFirst.Size = new System.Drawing.Size(39, 37);
            this.simpleButtonFirst.TabIndex = 0;
            this.simpleButtonFirst.Click += new System.EventHandler(this.simpleButtonFirst_Click);
            // 
            // MgncPager
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.panelControl1);
            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
            this.Name = "MgncPager";
            this.Size = new System.Drawing.Size(1089, 41);
            ((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
            this.panelControl1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.textEditToPage.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEditAllPageCount.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.comboBoxEditPageSize.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.textEditCurPage.Properties)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private DevExpress.XtraEditors.PanelControl panelControl1;
        private DevExpress.XtraEditors.TextEdit textEditCurPage;
        private DevExpress.XtraEditors.SimpleButton simpleButtonExportAllPage;
        private DevExpress.XtraEditors.SimpleButton simpleButtonExportCurPage;
        private DevExpress.XtraEditors.SimpleButton simpleButtonEnd;
        private DevExpress.XtraEditors.SimpleButton simpleButtonNext;
        private DevExpress.XtraEditors.SimpleButton simpleButtonPre;
        private DevExpress.XtraEditors.SimpleButton simpleButtonFirst;
        private DevExpress.XtraEditors.LabelControl labelControl1;
        private DevExpress.XtraEditors.ComboBoxEdit comboBoxEditPageSize;
        private DevExpress.XtraEditors.TextEdit textEditToPage;
        private DevExpress.XtraEditors.LabelControl labelControl2;
        private DevExpress.XtraEditors.LabelControl lcStatus;
        private DevExpress.XtraEditors.SimpleButton simpleButtonToPage;
        private DevExpress.XtraEditors.TextEdit textEditAllPageCount;
        private DevExpress.XtraEditors.LabelControl labelControl4;
    }
}

If you don't like to move and organize yourself, you can get 1 point from this address: http://download.csdn.net/detail/flyman105/9906644

This control is a preliminary framework. Different requirements, such as classification query, need to be modified accordingly

In c ා development, many people do not recommend using paging. It is also very fast to export 10000 records from the database. Moreover, the target users will not see so many paging

Published 336 original articles, won praise 1, visited 5161
Private letter follow

Topics: Windows Database SQL Excel