C# devexpress gridcontrol 分页 控件制作

2023-05-16

 这个小小的功能实现起来还是有一点点复杂, 分页单独一个usercontrol 出来,导致查询换页 与gridcontrol页面分离,  一般通过换页事件通知girdcontrol 做出查询

查询来说有时是查询所有,有时是查询一个月,或者别的时间. 在分页控件内的控件上做相应的赋值.想想实现起来还是有一定的复杂度.

如果数据量足够大 : 第一步是先查出数据总量,根据总量,把分页上的 数量,页数.当前页等做初始化,把第一页的数据通过数据库查询先赋值给gridcontrol,其余页面等用户点击时进行赋值

查询数据总数:

 

  /// <summary>
        /// 查询记录条数
        /// </summary>
        /// <returns>记录条数</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;
            }

        }

 

数据库查询分页代码:

 

   /// <summary>
        /// 分页
        /// </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;
            }

        }

 

分页控件样式图

新建一个usercontrol , 加上panelcontorl  然后 从左到右 需 button , 输入框,下拉框 ,labelcontrol 挨个拖进  

代码如下:

 

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);//单页,所有
        public event MyPagerEvents myPagerEvents;
        public event ExportEvents exportEvents;
        public MgncPager()
        {
            InitializeComponent();
        }
        //计算分页,分页大小,总记录数。
        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("(共{0}条记录,每页{1}条,共{2}页)", 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);
            }
            
        }
        //获取总记录数
        public int GetAllCount()
        {
            return allCount;
        }
        //获得当前页编号,从1开始
        public int GetCurPage()
        {
            return curPage;
        }
        //获得总页数
        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)
            {

            }
        }
    }
}

 

调用:

加两个事件:

    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)//单页,所有      
        {
            //导出GridControl代码写在这。
        }
        public void RefreshGridList()
        {
            FillGridListCtrlQuery(curPage);//自己实现FillGridListCtrlQuery函数。      
        }

        private void FillGridListCtrlQuery(int curPage = 1)   //更新控件
        {
       //  GridControl1.DataSource = WebService.Pager(。。。。。//显示分页结果
        mgncPager1.RefreshPager(pageSize, allcount, curPage);//更新分页控件显示。
        }
        private void MyPagerEvents(int curPage, int pageSize)
        {
            this.curPage = curPage;
            this.pageSize = pageSize;
            FillGridListCtrlQuery(curPage);

        }

 

  mgncPager1.RefreshPager(pageSize, allcount, curPage);//更新分页控件显示。  

每次查询数据量大需要分页,需要初始化这个控件上的值.

这边上还没实现数据保存,可以借鉴 别的博文里边你的文章,下边有上一页下一页  操作代码,包括内容导出

 

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;     //每页显示行数  
        private int nMax = 0;         //总记录数  
        private int pageCount = 0;    //页数=总记录数/每页显示行数  
        private int pageCurrent = 0;   //当前页号  
        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";   //数据库连接字符串  
            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);    //计算出总页数  
  
            if ((nMax % pageSize) > 0) pageCount++;  
  
            pageCurrent = 1;    //当前页数从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 == "导出当前页")  
            {  
                SaveFileDialog saveFileDialog = new SaveFileDialog();  
                saveFileDialog.Title = "导出Excel";  
                saveFileDialog.Filter = "Excel文件(*.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("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);  
                }    
            }  
                if (e.ClickedItem.Text == "关闭")  
                {  
                    this.Close();  
                }  
                if (e.ClickedItem.Text == "首页")  
                {  
                    pageCurrent--;  
                    if (pageCurrent <= 0)  
                    {  
                        MessageBox.Show("已经是首页,请点击“下一页”查看!");  
                        return;  
                    }  
                    else  
                    {  
                        pageCurrent = 1;  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "上一页")  
                {  
                    pageCurrent--;  
                    if (pageCurrent <= 0)  
                    {  
                        MessageBox.Show("已经是第一页,请点击“下一页”查看!");  
                        return;  
                    }  
                    else  
                    {  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "下一页")  
                {  
                    pageCurrent++;  
                    if (pageCurrent > pageCount)  
                    {  
                        MessageBox.Show("已经是最后一页,请点击“上一页”查看!");  
                        return;  
                    }  
                    else  
                    {  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);  
                    }  
                }  
                if (e.ClickedItem.Text == "尾页")  
                {  
                    pageCurrent++;  
                    if (pageCurrent > pageCount)  
                    {  
                        MessageBox.Show("已经是尾页,请点击“上一页”查看!");  
                        return;  
                    }  
                    else  
                    {  
                        pageCurrent = pageCount;  
                        dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCount, pageSize);  
                    }  
                }  
                LoadData();  
        }  
       
    }  
}  

 

 

 附 控件MgncPager.Designer.cs

 

namespace WORKALERT
{
    partial class MgncPager
    {
        /// <summary> 
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region 组件设计器生成的代码

        /// <summary> 
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </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 = "(共XXX条记录,每页XX条,共XX页)";
            // 
            // 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 = "跳转";
            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 = "当前页:";
            // 
            // 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 = "导出当前页";
            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 = "导出全部页";
            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 = "总页数:";
            // 
            // 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 = " 分页大小:";
            // 
            // 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;
    }
}

复制代码

不爱动弹自己整理就从这个地址下1分:http://download.csdn.net/detail/flyman105/9906644

这个控件是个初步框架,里边添不同的需求,比如分类查询,还需要做相应修改.

在c#开发中很多人不建议使用分页, 数据库导出1万条记录也很快,   再有就是目标用户也不会看那么多分页. 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C# devexpress gridcontrol 分页 控件制作 的相关文章

  • C# devexpress gridcontrol 分页 控件制作

    这个小小的功能实现起来还是有一点点复杂 分页单独一个usercontrol 出来 导致查询换页 与gridcontrol页面分离 一般通过换页事件通知girdcontrol 做出查询 查询来说有时是查询所有 有时是查询一个月 或者别的时间
  • winform 中 Devexpress Charts动态添加数据

    参考 Devexpress Charts动态添加数据 https www cnblogs com zhangruisoldier p 4226950 html DevExpress 图表控件 ChartControl 动态绑定数据 http
  • PopupMenu控件的使用

    1 用PopupMenu控件能进行右键菜单的实现 它的实现还需要绑定到barManager控件上 在barManager的Customize中添加右键所需要显示的功能 2 PopupMenu属性栏中绑定Manager为barManager
  • 「干货分享」DevExpress常用控件——RichEditControl使用指南

    做WinForms的一般都知道 传统 NET界面有一个RichTextBox控件 这个是一个富文本控件 可以存储图片文字等内容 它有自己的文件格式RTF 在DevExpress控件组里面也有一个同等的控件 他的名字是RichEditCont
  • 从对象生成 DTO

    我想从我现有的一些对象中自动生成一些 DTO 我想知道是否已经存在可以使用的 Resharper DevExpress 或 VSX 开源工具 我需要一个工具来查看我的代码并让我选择我想要的属性包含在我的 DTO 中 然后基于该生成一个类 另
  • 如何从 MVC 中的 Javascript 代码将值传递到控制器

    实际上我有一个这样的场景 我通过 Javascript 获取 GridView 中检查记录的值 现在我需要将这些值发送到控制器以删除这些记录
  • 以编程方式设置 XtraReport 中查看器表单的标题

    有谁知道如何在显示 XtraReport 文档时设置表单查看器的标题 场景如下 我配置了 XtraReport 报告 调用 ShowPreviewDialog 方法显示它 查看器表单打开并显示文档 我需要为此查看器表单设置标题 但找不到完成
  • WPF应用实战开发指南 - 如何实现动态内容展示

    在我们开发一些复杂信息的时候 由于需要动态展示一些相关信息 因此我们需要考虑一些控件内容的动态展示 可以通过动态构建控件的方式进行显示 如动态选项卡展示不同的信息 或者动态展示一个自定义控件的内容等等 目的就是能够减少一些硬编码的处理方式
  • 界面控件DevExpress WPF Dock组件,轻松创建类Visual Studio窗口界面!

    本文主要为大家介绍 DevExpress WPF 控件中的Dock组件 它能帮助用户轻松创还能受Microsoft Visual Studio启发的Dock窗口界面 P S DevExpress WPF拥有120 个控件和库 将帮助您交付满
  • 我可以更改 CodeRush Express for Visual Studio 免费版上的按键绑定吗?

    注意 我尝试在 coderush devexpress 论坛上发帖 但像往常一样 没有收到任何回复 希望一些 SO 用户使用 coderush express 并可能提供帮助 你好 我刚刚安装了免费的 CodeRush XPress 插件
  • 删除网格视图选项

    如何删除 显示分组依据框 和 删除此列 GridView菜单 当我去参加活动时 没有 ShowGridMenu 事件 所以对我不起作用 Use the GridView PopupMenuShowing http documentation
  • 带有未绑定列的 Devexpress 网格

    我有一个 DevExpress 网格 我想在其中添加一个未绑定的复选框以便能够选择某些项目 选择完成后 我按下一个按钮 我必须循环网格才能获取所有选定的项目 它必须是一个复选框 我尝试过使用多选网格 但用户无法使用它 我已经尝试了在支持网站
  • DX TreeList - 如何更改某些节点的颜色

    我有 DX treeList 它有一些功能 如复制 粘贴 删除等 如何在 C 代码中将某些节点颜色更改为其他颜色 你可以看一下here http 64 237 51 130 Help document XtraTreeList 单个细胞的外
  • 如何更改 DevExpress GridView 中行的背景色?

    我的表单中有一个 DevExpress GridView 由于布尔值 我需要更改一些行的颜色 允许我更改行的背景色的属性是什么 您可以在中更改行的颜色渐变RowStyle事件处理程序 private void myGridView RowS
  • 界面组件DevExpress WPF v23.2 - 更轻量级的主题支持

    DevExpress WPF Subscription拥有120 个控件和库 将帮助您交付满足甚至超出企业需求的高性能业务应用程序 通过DevExpress WPF能创建有着强大互动功能的XAML基础应用程序 这些应用程序专注于当代客户的需
  • Devexpress 在 razor mvc3 中添加报告时出错

    我正在尝试在我的 MVC 3 Web 应用程序中使用 DevExpress 报告 此应用程序是普通的 MVC 3 应用程序 而不是 DevExpress MVC 3 应用程序 使用以下教程添加 XtraReportshttp documen
  • 无需安装.net4.5即可运行webapi

    我有一个在asp net4 0下运行aspx页面的网站 我还有一些 DevExpress 控件 是我 4 年前购买的 我现在想向 Web 应用程序添加一个 API 但我知道这需要 net4 5 才能运行 DevExpress 控件在 4 5
  • 界面组件DevExpress ASP.NET Core v23.2 - 拥有全新的主题样式

    DevExpress ASP NET Core Controls使用强大的混合方法 结合现代企业Web开发工具所期望的所有功能 该套件通过ASP NET Razor标记和服务器端ASP NET Core Web API的生产力和简便性 提供
  • 如何以 0,00 格式显示价格(即一百 100,00)

    hii 我正在使用 devexpress 网格控件 在我的网格中有价格选项卡 因为我希望价格列以 0 00 格式显示 即如果我的价格是 3000 那么它应该显示 3 000 00 请帮助我 它是针对 winforms 的 前端是 c Dev
  • 如何使用 NPOI 获取包含日期的单元格的值并保留原始格式

    我有一个使用 DevExpress 编辑的 Excel 文件 并且正在使用 NPOI 阅读 当我尝试以字符串形式获取日期单元格的值时 它不会保留原始值 例如 在 DevExpress 网格中我设置了这个值 2016 08 12 我想在字符串

随机推荐

  • 用tkinter写出you-get下载器界面,并用pyinstaller打包成exe文件

    写在前面 xff1a 本文为笔者最早于 2019 05 11 23 15 以 64 拼命三郎 的身份发表于博客园 本文为原创文章 xff0c 转载请标明出处 一 you get介绍 you get是一个基于 python3 的下载工具 xf
  • Linux网络协议栈4--bridge收发包

    bridge 是linux上的虚拟交换机 xff0c 具有交换机的功能 网卡收到包后 xff0c 走到 netif receive skb core后 xff0c 剥完vlan找到vlan子接口 xff08 如果有的话 xff09 xff0
  • linux redis启动时报错WARNING overcommit_memory is set to 0! Background save may fail under low memory con

    报错 xff1a WARNING overcommit memory is set to 0 Background save may fail under low memory condition To fix this issue add
  • STM32编程语言介绍

    STM32入门100步 第8期 编程语言介绍 杜洋 洋桃电子 上一期我们在电脑上安装好了KEIL软件 xff0c 也新建了工程 xff0c 在工程中安装了固件库 准备工作完成后 xff0c 接着就是在工程中编写程序了 只有程序使ARM内核有
  • VMware虚拟机安装Linux教程(超详细)

    写给读者 为了帮助Linux系统初学者学习的小伙伴更好的学习 xff0c VMware虚拟机是不可避免的 xff0c 因此下载 安装VMware和完成Linux的系统安装是非常必要的 接下来 xff0c 我们就来系统的学习一下VMware虚
  • Markdown中的LaTeX公式——希腊字母详解

    若要在Markdown中使用 xff0c 则在两个美元符号之间敲入对应LaTeX代码实现公式行显示效果 xff0c 若为公式块 xff0c 则要在四个美元符号中间敲入 xff0c 类似Markdown代码行和代码块 共24个希腊字母 xff
  • FFmpeg学习(一)-- ffmpeg 播放器的基础

    FFmpeg学习 xff08 一 xff09 FFmpeg学习 xff08 二 xff09 FFmpeg学习 xff08 三 xff09 FFmpeg的的是一套可以用来记录 xff0c 转换数字音频 xff0c 视频 xff0c 并能将其转
  • ios Instruments之Allocations

    文章目录 一 span class hljs function Allocations 监测内存分配 span 1 简介 2 如何使用 一 Allocations 1 简介 性能优化中使用Instruments Allocations工具进
  • linux-Centos-7-64位:4、 mysql安装

    从最新版本的Linux系统开始 xff0c 默认的是 Mariadb而不是MySQL xff01 这里依旧以mysql为例进行展示 1 先检查系统是否装有mysql rpm qa span class hljs string style c
  • Win10 WSL忘记用户密码,重置密码

    win10中WSL登录是不用密码的 xff0c 当需要使用用户权限但是忘记密码的时候 xff0c 可以使用如下办法以root身份登录WSL并重置密码 1 以管理员身份打开 PowerShell 2 输入命令 wsl exe user roo
  • 51单片机定时时间的计算

    单片机根据计时 计数模式的不同 xff0c 来进行计算 M1 M0 工作模式 说明 0 0 0 13位计时计数器 xff08 8192 xff09 0 1 1 16位计时计数器 xff08 65536 xff09 1 0 2 8位计时计数器
  • Go语言之禅

    本文翻译自Go社区知名Gopher和博主Dave Cheney的文章 The Zen of Go 本文来自我在GopherCon Israel 2020上的演讲 文章很长 如果您希望阅读精简版 xff0c 请移步到the zen of go
  • UIScrollView及其子类停止滚动的监测

    作为iOS中最重要的滑动控件 UIScrollView居然没有停止滚动的Delegate方法 这有点蛋疼 但是我们可以根据滚动状态来判断是否滚动 span class hljs preprocessor pragma mark scroll
  • PCL库中Marching Cubes(移动立方体)算法的解析

    PCL库中Marching Cubes xff08 移动立方体 xff09 算法解析 1 Marching Cubes算法的原理这里不再赘述 xff0c 不懂的话 xff0c 提供一下文献资源 xff1a 链接 xff1a MARCHING
  • ubuntu18.04安装cuda-10.0和cudnn-7.4.2

    安装cuda 10 0 1 gcc 版本 Ubuntu18 04默认gcc g 43 43 7 3版本 xff0c 如果安装cuda 9并不支持 gcc g 43 43 7 xff0c 所以先降级至6或6以下 我自己的gcc是7 5 0 安
  • Ubuntu安装anaconda3后找不到conda命令

    Ubuntu安装anaconda3后找不到conda命令的原因是没有把anaconda3添加到路径 xff0c 类似于Windows中添加到环境变量 xff0c 所以找不到命令 解决方法是在终端中运行一下命令 xff1a echo 39 e
  • uCharts Y轴格式化

    官方文档 uCharts跨平台图表库 1 Y轴格式化用法 xff1a yAxis data calibration true position 39 left 39 title 39 折线 39 titleFontSize 12 forma
  • C#/.NET Winform 界面库UI推荐

    以下是C CSkin界面库的官方板块 xff1a http bbs cskin net thread 622 1 1 html 几款开源的Windows界面库 https blog csdn net blade2001 article de
  • layui中实现按钮点击事件

    首先 xff0c 小编要告诉大家一个残酷的现实 xff0c 那就是小编没有找到layui对点击事件的支持 这里的点击事件是指单纯的点击事件 xff0c 而不是提交事件 xff0c 或者是数据表格中内嵌的button xff0c 对于这两者
  • C# devexpress gridcontrol 分页 控件制作

    这个小小的功能实现起来还是有一点点复杂 分页单独一个usercontrol 出来 导致查询换页 与gridcontrol页面分离 一般通过换页事件通知girdcontrol 做出查询 查询来说有时是查询所有 有时是查询一个月 或者别的时间