这个是我在项目中用到的,附件中是源码,有需要的可以根据自己的需求进行改进,项目中引用“WinformPager.dll”这个动态库就可以在工具栏中看到该控件了,下面是大概的用法,希望对你有用。控件保证能用,不会用的请勿乱喷。不懂可以加我QQ:936052556 第一步:将控件拖至窗体指定处,注意没有界面的。 第二步:查看控件属性-->事件-->PageChanged 事件 第三步:数据查询事件中指定“RecordCount”属性,指定这个属性会触发 PageChanged 事件; 例如: private DataTable DataSource; private void btn_query_Click(object sender, EventArgs e) { DataSource=GetData(); winFormPager1.RecordCount =dt.Rows.Count; } //分页控件分页事件 private void winFormPager1_PageChanged() { GV_First.DataSource = DataPaging(DataSource, winFormPager1.CurrentPage, winFormPager1.PageSize); } 方法“DataPaging”是我自己按照项目需求写的,是一次性查询出来放内存中的,然后再内存中进行分页,代码如下: /// <summary> /// 数据分页 /// </summary> /// <param name="dt"></param> /// <param name="Currentpage"></param> /// <param name="pagecount"></param> /// <returns></returns> DataTable DataPaging(DataTable dt, int Currentpage, int pagecount) { if (dt == null || dt.Rows.Count == 0) return dt; DataTable pagdata = dt.Clone(); for (int i = (Currentpage - 1) * pagecount; i < pagecount * Currentpage && i < dt.Rows.Count; i++) { pagdata.ImportRow(dt.Rows[i]); } return pagdata; }
- 1
- 粉丝: 7
- 资源: 15
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
- 1
- 2
- 3
前往页