这个小小的功能实现起来还是有一点点复杂, 分页单独一个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万条记录也很快, 再有就是目标用户也不会看那么多分页.