-
大小: 218KB文件類(lèi)型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-20
- 語(yǔ)言: C#
- 標(biāo)簽: Datagridview??
資源簡(jiǎn)介
C#開(kāi)發(fā)的Datagridview分頁(yè)控件源碼,采用的真分頁(yè)非存儲(chǔ)過(guò)程方式。支持每頁(yè)顯示條數(shù),頁(yè)跳轉(zhuǎn),當(dāng)前頁(yè)和全部頁(yè)導(dǎo)出Excel功能。
使用方法。將本控件源碼導(dǎo)入自己的新建項(xiàng)目中,整個(gè)項(xiàng)目編譯一次后,工具箱會(huì)自動(dòng)生成一個(gè)第三方控件名稱(chēng)叫DataPager。在winForm上的datagridview控件下拖入本控件,設(shè)置好每頁(yè)顯示的最大記錄條數(shù)(默認(rèn)為50條記錄)即可。代碼中加入以下代碼 this.dataPager1.RelationControl(this.Dgv);//本控件并聯(lián)的datagridview控件名。 this.dataPager1.DataSource = ds.Tables[0];//本控件的數(shù)據(jù)源.

代碼片段和文件信息
using?System;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.IO;
using?System.Text;
using?System.Text.Regularexpressions;
using?System.Windows.Forms;
namespace?DataGridViewPagerControl
{
????#region?定義按鈕單擊事件的委托
????//【1】定義按鈕單擊事件的“委托”(參數(shù))
????public?delegate?void?PagerQueryDelegate(string?sqlString);
????public?delegate?void?DataSetToExcel(string?sqlString);
????#endregion
????[ToolboxBitmap(t:?typeof(PagerControl)?name:?“App.ico“)]
????public?partial?class?PagerControl?:?UserControl
????{
????????#region?委托事件
????????//【2】定義分頁(yè)按鈕“單擊事件”(實(shí)際調(diào)用使用的方法)
????????public?event?PagerQueryDelegate?ExecQueryEventHandler;
????????public?event?DataSetToExcel?ExecDataSetToExcelEventHandler;
????????#endregion
????????#region?參數(shù)
????????private?int?_recordCount;//記錄總數(shù)
????????private?int?_pageSize;//每頁(yè)顯示多少條記錄
????????private?int?_maxRecordPerPage?=?1000;//每頁(yè)最多顯示記錄數(shù)不能超過(guò)1000條
????????private?int?_pageCount;//分頁(yè)總數(shù)
????????private?int?_currentPagerIndex;//當(dāng)前頁(yè)碼
????????private?string?_tableName;//要查詢(xún)的表或視圖
????????private?string[]?_filedNameArray;//需要顯示的字段名數(shù)組
????????private?string?_keyword;//主鍵或查詢(xún)關(guān)鍵字
????????private?string?_whereString;//查詢(xún)條件
????????private?string?_sortString;//排序條件
????????#endregion
????????#region?屬性
????????///?
????????///?記錄總數(shù)
????????///?
????????public?int?RecordCount
????????{
????????????get?{?return?_recordCount;?}
????????????set?{?_recordCount?=?value;?}
????????}
????????[BrowsableAttribute(true)?DefaultValue(“50“)?Description(“設(shè)置每頁(yè)顯示的記錄條數(shù)“)?Category(“數(shù)據(jù)“)]
????????///?
????????///?分頁(yè)大小每頁(yè)顯示多少條記錄
????????///?
????????public?int?PageSize
????????{
????????????get?{?return?_pageSize;?}
????????????set
????????????{
????????????????_pageSize?=?value;
????????????????if?(_pageSize?!=?0)
????????????????{
????????????????????this.CmbPageSize.Text?=?_pageSize.ToString();
????????????????}
????????????????else
????????????????{
????????????????????this.CmbPageSize.Text?=?“50“;
????????????????????_pageSize?=?50;
????????????????}
????????????????this.Invalidate();
????????????}
????????}
????????[BrowsableAttribute(true)?DefaultValue(“1000“)?Description(“設(shè)置每頁(yè)可顯示記錄的最大值“)?Category(“數(shù)據(jù)“)]
????????///?
????????///?每頁(yè)最多顯示記錄數(shù)不能超過(guò)默認(rèn)1000條
????????///?
????????public?int?MaxRecordPerPage
????????{
????????????get?{?return?_maxRecordPerPage;?}
????????????set?{?_maxRecordPerPage?=?value;?}
????????}
????????///?
????????///?總頁(yè)數(shù)
????????///? ????????
????????public?int?PageCount
????????{
????????????get
????????????{
????????????????if?(PageSize?!=?0)
????????????????{
????????????????????if?(RecordCount?%?PageSize?==?0)
????????????????????{
????????????????????????_pageCount?=?RecordCount?/?PageSize;
????????????????????}
????????????????????else
????????????????????{
????????????????????????_pageCount?=?RecordCount?/?PageSize?+?1;
?????
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2018-11-26?17:49??PagerControl\
?????文件???????17542??2018-07-19?09:07??PagerControl\App.ico
?????文件???????16218??2018-10-27?17:26??PagerControl\DataGridViewPagerControl.Designer.cs
?????文件???????20391??2018-10-27?17:26??PagerControl\DataGridViewPagerControl.cs
?????文件????????3552??2018-11-24?09:21??PagerControl\DataGridViewPagerControl.csproj
?????文件?????????352??2018-07-19?09:03??PagerControl\DataGridViewPagerControl.csproj.user
?????文件???????33751??2018-10-27?17:26??PagerControl\DataGridViewPagerControl.resx
?????目錄???????????0??2018-11-26?17:49??PagerControl\Properties\
?????文件????????1402??2018-10-02?16:39??PagerControl\Properties\AssemblyInfo.cs
?????文件????????2889??2018-10-01?20:22??PagerControl\Properties\Resources.Designer.cs
?????文件????????5817??2018-07-12?16:42??PagerControl\Properties\Resources.resx
?????目錄???????????0??2018-11-26?17:49??PagerControl\bin\
?????目錄???????????0??2018-11-26?17:49??PagerControl\bin\Debug\
?????文件???????44544??2018-11-24?09:24??PagerControl\bin\Debug\DataGridViewPagerControl.dll
?????文件???????32256??2018-11-24?09:24??PagerControl\bin\Debug\DataGridViewPagerControl.pdb
?????文件??????101888??2018-07-20?10:14??PagerControl\bin\Debug\HRPM.Common.dll
?????文件???????75264??2018-07-20?10:14??PagerControl\bin\Debug\HRPM.Common.pdb
?????目錄???????????0??2018-11-26?17:49??PagerControl\bin\Release\
?????文件???????41984??2018-07-19?08:53??PagerControl\bin\Release\DataGridViewPagerControl.dll
?????文件???????30208??2018-07-19?08:53??PagerControl\bin\Release\DataGridViewPagerControl.pdb
?????目錄???????????0??2018-11-26?17:49??PagerControl\obj\
?????目錄???????????0??2018-11-26?17:49??PagerControl\obj\Debug\
?????文件???????18783??2018-11-24?09:24??PagerControl\obj\Debug\DataGridViewPagerControl.PagerControl.resources
?????文件?????????180??2018-11-24?09:24??PagerControl\obj\Debug\DataGridViewPagerControl.Properties.Resources.resources
?????文件???????????0??2018-07-13?14:29??PagerControl\obj\Debug\DataGridViewPagerControl.csproj.CopyComplete
?????文件??????????42??2018-10-26?11:16??PagerControl\obj\Debug\DataGridViewPagerControl.csproj.CoreCompileInputs.cache
?????文件????????3660??2018-10-26?17:27??PagerControl\obj\Debug\DataGridViewPagerControl.csproj.FileListAbsolute.txt
?????文件????????1031??2018-10-28?14:36??PagerControl\obj\Debug\DataGridViewPagerControl.csproj.GenerateResource.Cache
?????文件????????4191??2018-10-26?17:26??PagerControl\obj\Debug\DataGridViewPagerControl.csprojResolveAssemblyReference.cache
?????文件???????44544??2018-11-24?09:24??PagerControl\obj\Debug\DataGridViewPagerControl.dll
?????文件???????32256??2018-11-24?09:24??PagerControl\obj\Debug\DataGridViewPagerControl.pdb
............此處省略26個(gè)文件信息
評(píng)論
共有 條評(píng)論