這個小小的功能實現起來還是有一點點復雜, 分頁單獨一個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萬條記錄也很快, 再有就是目標用戶也不會看那么多分頁.