C# devexpress gridcontrol 分页 控件制作
这个小小的功能实现起来还是有一点点复杂, 分页单独一个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 = ;
private int pageSize = ;
private int curPage = ;
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 == )
{
if (GetPageCount() > )
{
curPage = ;
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 = ;
if (allCount % pageSize == )
{
count = allCount / pageSize;
}
else
count = allCount / pageSize+;
return count;
} private void simpleButtonNext_Click(object sender, EventArgs e)
{
if (myPagerEvents != null)
{
if(curPage<GetPageCount())
curPage += ;
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 > )
curPage -= ;
myPagerEvents(curPage, pageSize);
}
} private void simpleButtonFirst_Click(object sender, EventArgs e)
{
if (myPagerEvents != null)
{ curPage = ;
myPagerEvents(curPage, pageSize);
}
} private void simpleButtonToPage_Click(object sender, EventArgs e)
{
try
{
int selPage = Convert.ToInt32(textEditToPage.Text);
if (myPagerEvents != null)
{
if ((selPage >= ) && (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 > ))
{
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 = ;
public int pageSize = ;
public int allcount = ;
public void ExportEvents(bool singlePage)//单页,所有
{
//导出GridControl代码写在这。
}
public void RefreshGridList()
{
FillGridListCtrlQuery(curPage);//自己实现FillGridListCtrlQuery函数。
} private void FillGridListCtrlQuery(int curPage = ) //更新控件
{
// 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 = ; //每页显示行数
private int nMax = ; //总记录数
private int pageCount = ; //页数=总记录数/每页显示行数
private int pageCurrent = ; //当前页号
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[]; 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[].Rows[]["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) > ) pageCount++; pageCurrent = ; //当前页数从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 <= )
{
MessageBox.Show("已经是首页,请点击“下一页”查看!");
return;
}
else
{
pageCurrent = ;
dtInfo = sp.ExecuteDataTable("DZ_LoginLog", "Id", "Id desc", pageCurrent, pageSize);
}
}
if (e.ClickedItem.Text == "上一页")
{
pageCurrent--;
if (pageCurrent <= )
{
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(, );
this.panelControl1.Margin = new System.Windows.Forms.Padding(, , , );
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(, );
this.panelControl1.TabIndex = ;
//
// lcStatus
//
this.lcStatus.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
this.lcStatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.lcStatus.Location = new System.Drawing.Point(, );
this.lcStatus.Margin = new System.Windows.Forms.Padding(, , , );
this.lcStatus.Name = "lcStatus";
this.lcStatus.Padding = new System.Windows.Forms.Padding(, , , );
this.lcStatus.Size = new System.Drawing.Size(, );
this.lcStatus.TabIndex = ;
this.lcStatus.Text = "(共XXX条记录,每页XX条,共XX页)";
//
// simpleButtonToPage
//
this.simpleButtonToPage.Dock = System.Windows.Forms.DockStyle.Left;
this.simpleButtonToPage.Location = new System.Drawing.Point(, );
this.simpleButtonToPage.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonToPage.Name = "simpleButtonToPage";
this.simpleButtonToPage.Size = new System.Drawing.Size(, );
this.simpleButtonToPage.TabIndex = ;
this.simpleButtonToPage.Text = "跳转";
this.simpleButtonToPage.Click += new System.EventHandler(this.simpleButtonToPage_Click);
//
// textEditToPage
//
this.textEditToPage.Dock = System.Windows.Forms.DockStyle.Left;
this.textEditToPage.EditValue = "";
this.textEditToPage.Location = new System.Drawing.Point(, );
this.textEditToPage.Margin = new System.Windows.Forms.Padding(, , , );
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(, );
this.textEditToPage.TabIndex = ;
//
// labelControl2
//
this.labelControl2.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
this.labelControl2.Dock = System.Windows.Forms.DockStyle.Left;
this.labelControl2.Location = new System.Drawing.Point(, );
this.labelControl2.Margin = new System.Windows.Forms.Padding(, , , );
this.labelControl2.Name = "labelControl2";
this.labelControl2.Size = new System.Drawing.Size(, );
this.labelControl2.TabIndex = ;
this.labelControl2.Text = "当前页:";
//
// simpleButtonExportCurPage
//
this.simpleButtonExportCurPage.Dock = System.Windows.Forms.DockStyle.Right;
this.simpleButtonExportCurPage.Location = new System.Drawing.Point(, );
this.simpleButtonExportCurPage.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonExportCurPage.Name = "simpleButtonExportCurPage";
this.simpleButtonExportCurPage.Size = new System.Drawing.Size(, );
this.simpleButtonExportCurPage.TabIndex = ;
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(, );
this.simpleButtonExportAllPage.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonExportAllPage.Name = "simpleButtonExportAllPage";
this.simpleButtonExportAllPage.Size = new System.Drawing.Size(, );
this.simpleButtonExportAllPage.TabIndex = ;
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(, );
this.textEditAllPageCount.Margin = new System.Windows.Forms.Padding(, , , );
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(, );
this.textEditAllPageCount.TabIndex = ;
//
// labelControl4
//
this.labelControl4.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None;
this.labelControl4.Dock = System.Windows.Forms.DockStyle.Left;
this.labelControl4.Location = new System.Drawing.Point(, );
this.labelControl4.Margin = new System.Windows.Forms.Padding(, , , );
this.labelControl4.Name = "labelControl4";
this.labelControl4.Size = new System.Drawing.Size(, );
this.labelControl4.TabIndex = ;
this.labelControl4.Text = "总页数:";
//
// comboBoxEditPageSize
//
this.comboBoxEditPageSize.Dock = System.Windows.Forms.DockStyle.Left;
this.comboBoxEditPageSize.EditValue = "";
this.comboBoxEditPageSize.Location = new System.Drawing.Point(, );
this.comboBoxEditPageSize.Margin = new System.Windows.Forms.Padding(, , , );
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 = ;
this.comboBoxEditPageSize.Properties.Items.AddRange(new object[] {
"",
"",
"",
"",
"",
""});
this.comboBoxEditPageSize.Size = new System.Drawing.Size(, );
this.comboBoxEditPageSize.TabIndex = ;
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(, );
this.labelControl1.Margin = new System.Windows.Forms.Padding(, , , );
this.labelControl1.Name = "labelControl1";
this.labelControl1.Size = new System.Drawing.Size(, );
this.labelControl1.TabIndex = ;
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(, );
this.simpleButtonEnd.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonEnd.Name = "simpleButtonEnd";
this.simpleButtonEnd.Size = new System.Drawing.Size(, );
this.simpleButtonEnd.TabIndex = ;
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(, );
this.simpleButtonNext.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonNext.Name = "simpleButtonNext";
this.simpleButtonNext.Size = new System.Drawing.Size(, );
this.simpleButtonNext.TabIndex = ;
this.simpleButtonNext.Click += new System.EventHandler(this.simpleButtonNext_Click);
//
// textEditCurPage
//
this.textEditCurPage.Dock = System.Windows.Forms.DockStyle.Left;
this.textEditCurPage.EditValue = "";
this.textEditCurPage.Location = new System.Drawing.Point(, );
this.textEditCurPage.Margin = new System.Windows.Forms.Padding(, , , );
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(, );
this.textEditCurPage.TabIndex = ;
//
// 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(, );
this.simpleButtonPre.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonPre.Name = "simpleButtonPre";
this.simpleButtonPre.Size = new System.Drawing.Size(, );
this.simpleButtonPre.TabIndex = ;
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(, );
this.simpleButtonFirst.Margin = new System.Windows.Forms.Padding(, , , );
this.simpleButtonFirst.Name = "simpleButtonFirst";
this.simpleButtonFirst.Size = new System.Drawing.Size(, );
this.simpleButtonFirst.TabIndex = ;
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(, , , );
this.Name = "MgncPager";
this.Size = new System.Drawing.Size(, );
((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万条记录也很快, 再有就是目标用户也不会看那么多分页.
C# devexpress gridcontrol 分页 控件制作的更多相关文章
- [原创]WinForm分页控件制作
先简单说一下思路: 1.做一个分页控件的导航类,即记录总页数.当前页.每页记录数,下一页.上一页.跳转等操作的页数变更. class PageNavigation{/// <summary> ...
- 在DevExpress程序中使用Winform分页控件直接录入数据并保存
一般情况下,我们都倾向于使用一个组织比较好的独立界面来录入或者展示相关的数据,这样处理比较规范,也方便显示比较复杂的数据.不过在一些情况下,我们也可能需要直接在GridView表格上直接录入或者修改数 ...
- CS系统中分页控件的制作
需求:在一个已有的CS项目(ERP中),给所有的列表加上分页功能. 分页的几个概念: 总记录数 totalCount (只有知道了总记录数,才知道有多少页) 每页记录数 pageSize (根据总 ...
- 如何Windows分页控件中增加统计功能
在我的博客里面,很多Winform程序里面都用到了分页处理,这样可以不管是在直接访问数据库的场景还是使用网络方式访问WCF服务获取数据,都能获得较好的效率,因此WInform程序里面的分页控件的使用是 ...
- 在GridControl表格控件中实现多层级主从表数据的展示
在一些应用场景中,我们需要实现多层级的数据表格显示,如常规的二级主从表数据展示,甚至也有多个层级展示的需求,那么我们如何通过DevExpress的GridControl控表格件实现这种业务需求呢?本篇 ...
- C# DataGridView自定义分页控件
好些日子不仔细写C#代码了,现在主要是Java项目,C#.Net相关项目不多了,有点手生了,以下代码不足之处望各位提出建议和批评. 近日闲来无事想研究一下自定义控件,虽然之前也看过,那也仅限于皮毛,粗 ...
- MvcPager 免费开源分页控件3.0版发布!
MvcPager 3.0版在原2.0版的基础上进行了较大的升级,对MvcPager脚本插件重写并进行了大量优化.修复了部分bug并新增了客户端Javascript API等功能,使用更方便,功能更强大 ...
- 纯手写分页控件CSS+JS+SQL
Asp.net中虽然用DataPager配合ListView可以实现分页显示,但是有时候由于开发环境等问题不能用到DataPager控件,那么自己手工写一个分页控件就很有必要了,当然,最重要的是通用性 ...
- DevExpress Winform 通用控件打印方法(允许可自定义边距) z
DevExpress Winform 通用控件打印方法,包括gridcontrol,treelist,pivotGridControl,ChartControl,LayoutControl...(所有 ...
随机推荐
- 使用jQuery+huandlebars遍历展示对象中的数组
兼容ie8(很实用,复制过来,仅供技术参考,更详细内容请看源地址:http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471227.html) & ...
- C#转成时间格式
public static string GetDatetime() { System.Globalization.DateTimeFormatInfo myDTF ...
- SQL思维导图总结
- waffit防火墙检测
Waffit是一款Web应用防火墙检测工具,检测防火墙保护的站点是在渗透测试中非常重要的一步.如果没有对WAF进行配置,有时候可能存在漏洞.在渗透测试和风险评估中分析WAF也是非常重要的.通过编码攻击 ...
- java.lang.IllegalArgumentException: Missing either @POST URL or @Url parameter.
以前联调的接口,都是类似这样子的http://ip:8080/WLInterface/register 在baseUrl(http://ip:8080/WLInterface/register ) ...
- Unity入门&物理引擎
一.Unity六大模块 首先,Unity界面有六大模块,分别是:Hierarchy,Scene,Game,Inspector,Project,Console.下面对这六个视图的功能进行详解. 1.Hi ...
- django models实际操作中遇到的一些问题
问题1.将主键id改成自动生成的python3 manage.py migrate时报下面的错误 django.db.utils.InternalError: (1091, "Can't D ...
- redis主从复制踩到的那些坑
一.报错:* MASTER <-> SLAVE sync started # Error condition on socket for SYNC: No route to host解决: ...
- cloudstack4.11+KVM+4网卡bond5+briage 交换机不作配置
网卡绑定配置 # cat ifcfg-em1TYPE=EthernetBOOTPROTO=noneDEVICE=em1ONBOOT=yesMASTER=bond0SLAVE=yes# cat ifcf ...
- pta l2-13(红色警报)
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805063963230208 题意:给n个顶点,m条边,问每次删 ...