资源简介
自己写的一个分页控件,可以实现dataGridView的分页显示!很值得下载看看!资源免费,大家分享!!
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace pageButton
{
public partial class PageButton : UserControl
{
private int currentPage = 0;
private int pageCount = 0;
private int totalSum = 0;
private int ApageNum = 5;
private DataTable dt = new DataTable();
private DataGridView dgv = new DataGridView();
public PageButton()
{
InitializeComponent();
init();
}
[DefaultValue(“5“) Description(“dataGridView“) Category(“Data“)]
public int getApageNun
{
get { return ApageNum; }
set { ApageNum = value; }
}
[DefaultValue(“null“) Description(“dataGridView“) Category(“Data“)]
public DataGridView dataGridView
{
get { return dgv; }
set { dgv = value; }
}
[DefaultValue(“null“) Description(“dataTable“) Category(“Data“)]
public DataTable dataTable
{
get { return dt; }
set { dt = value; }
}
public void init()
{
totalSum = dt.Rows.Count;
pageCount = 0;
if (totalSum <= 0)
{
nextBtn.Enabled = false;
lastBtn.Enabled = false;
firstBtn.Enabled = false;
preBtn.Enabled = false;
showMessage();
return;
}
pageCount = totalSum / ApageNum;
if (totalSum % ApageNum > 0)
pageCount++;
currentPage = 1;
firstBtn.Enabled = false;
preBtn.Enabled = false;
if (pageCount > 1)
{
nextBtn.Enabled = true;
lastBtn.Enabled = true;
}
else
{
nextBtn.Enabled = false;
lastBtn.Enabled = false;
}
if (totalSum > currentPage * ApageNum)
showData((currentPage - 1) * ApageNum + 1 currentPage * ApageNum);
else
showData((currentPage - 1) * ApageNum + 1 totalSum);
}
private void showMessage()
{
messageLab.Text = “第“ + currentPage.ToString() + “页/共“ + pageCount + “页共“ +
totalSum + “条记录“;
}
private void showData(int start int end)
{
showMessage();
DataTable tempTable = dt.Clone();
for (int i = start; i <= end; i++)
{
tempTable.ImportRow(dt.Rows[i - 1]);
}
dgv.DataSource = tempTable.DefaultView;
}
private void firstBtn_Click(object sender EventArgs e)
{
this.currentPage = 1;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1319 2007-09-23 16:08 pageButton\pageButton\Properties\AssemblyInfo.cs
文件 5817 2007-09-23 16:23 pageButton\pageButton\Properties\Resources.resx
文件 2843 2007-09-23 16:23 pageButton\pageButton\Properties\Resources.Designer.cs
目录 0 2007-09-23 16:08 pageButton\pageButton\Properties
文件 5527 2007-09-24 10:28 pageButton\pageButton\PageButton.Designer.cs
文件 5675 2007-09-24 11:03 pageButton\pageButton\PageButton.cs
文件 2909 2007-09-23 16:35 pageButton\pageButton\pageButton.csproj
文件 24576 2007-09-24 11:08 pageButton\pageButton\bin\Debug\pageButton.dll
文件 22016 2007-09-24 11:08 pageButton\pageButton\bin\Debug\pageButton.pdb
目录 0 2007-09-23 16:08 pageButton\pageButton\bin\Debug
目录 0 2007-09-23 16:08 pageButton\pageButton\bin
文件 4096 2007-09-23 16:23 pageButton\pageButton\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
目录 0 2007-09-23 16:08 pageButton\pageButton\obj\Debug\TempPE
目录 0 2007-09-23 16:09 pageButton\pageButton\obj\Debug\Refactor
文件 180 2007-09-24 11:08 pageButton\pageButton\obj\Debug\pageButton.Properties.Resources.resources
文件 180 2007-09-24 11:08 pageButton\pageButton\obj\Debug\pageButton.PageButton.resources
文件 847 2007-09-24 11:08 pageButton\pageButton\obj\Debug\pageButton.csproj.GenerateResource.Cache
文件 22016 2007-09-24 11:08 pageButton\pageButton\obj\Debug\pageButton.pdb
文件 24576 2007-09-24 11:08 pageButton\pageButton\obj\Debug\pageButton.dll
目录 0 2007-09-23 16:08 pageButton\pageButton\obj\Debug
文件 294 2007-09-24 11:08 pageButton\pageButton\obj\pageButton.csproj.FileList.txt
目录 0 2007-09-23 16:08 pageButton\pageButton\obj
文件 5987 2007-09-24 10:28 pageButton\pageButton\PageButton.resx
目录 0 2007-09-23 16:08 pageButton\pageButton
文件 919 2007-09-23 16:08 pageButton\pageButton.sln
..A..H. 12288 2007-09-24 10:30 pageButton\pageButton.suo
目录 0 2007-09-23 16:08 pageButton
文件 446270 2008-11-07 13:21 更多免费精品资源:点击访问.url
----------- --------- ---------- ----- ----
588335 28
............此处省略1个文件信息
相关资源
- CSharp实现消息框倒计时自动关闭窗口
- CSharp_Region类的方法使用图解
- ICSharpCode.SharpZipLib.dll下载55485
- CSharp个人通讯录程序源代码
- CSharp设计模式(23种设计模式)
- Csharp入门经典第五版源代码
- ICSharpCode.SharpZipLib.dll(版本号0.86.0.
- csharp实现计算器
- ICSharpCode.SharpZipLib
- ICSharpCode.SharpZipLib.dll 多文件打包压缩
- icsharpcode.sharpziplib.dll各版本包含 0.8
- ICSharpCode.SharpZipLib .net 4.0
- ICSharpCode.SharpZipLib.dll
- aliyun-oss-csharp-sdk-net-core
- unity读取excel文件的dll Excel.dll ICSha
- CSharp写的UDP例程
评论
共有 条评论