入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。
GitHub:https://github.com/kwwwvagaa/NetWinformControl
码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
https://www.cnblogs.com/bfyx/p/11364884.html
当一个列表加载数据过多时,比如datagridview,如果数据过多,则可能超出内存,相应慢等问题,此时需要用到翻页控件。
设计思路,对翻页控件定义接口,基类实现,如果所列的翻页控件样式或功能无法满足你的需求的话,你只需要基类翻页控件基类或者实现接口即可。
定义接口是因为后面的一些列表控件内置了翻页控件,为了达到兼容扩展,所有使用了接口定义约束。
首先需要一个分页事件用到的委托,偷懒,只写了一个
[Serializable]
[ComVisible(true)]
public delegate void PageControlEventHandler(object currentSource);
我们先定义一个接口IPageControl
1 public interface IPageControl
2 {
3 /// <summary>
4 /// 数据源改变时发生
5 /// </summary>
6 event PageControlEventHandler ShowSourceChanged;
7 /// <summary>
8 /// 数据源
9 /// </summary>
10 List<object> DataSource { get; set; }
11 /// <summary>
12 /// 显示数量
13 /// </summary>
14 int PageSize { get; set; }
15 /// <summary>
16 /// 开始下标
17 /// </summary>
18 int StartIndex { get; set; }
19 /// <summary>
20 /// 第一页
21 /// </summary>
22 void FirstPage();
23 /// <summary>
24 /// 前一页
25 /// </summary>
26 void PreviousPage();
27 /// <summary>
28 /// 下一页
29 /// </summary>
30 void NextPage();
31 /// <summary>
32 /// 最后一页
33 /// </summary>
34 void EndPage();
35 /// <summary>
36 /// 重新加载
37 /// </summary>
38 void Reload();
39 /// <summary>
40 /// 获取当前页数据
41 /// </summary>
42 /// <returns></returns>
43 List<object> GetCurrentSource();
44 /// <summary>
45 /// 总页数
46 /// </summary>
47 int PageCount { get; set; }
48 /// <summary>
49 /// 当前页
50 /// </summary>
51 int PageIndex { get; set; }
52 }
然后定义一个分页基类控件,添加一个用户控件,命名UCPagerControlBase,并实现接口IPageControl
看下属性
1 /// <summary>
2 /// 总页数
3 /// </summary>
4 public virtual int PageCount
5 {
6 get;
7 set;
8 }
9 private int m_pageIndex = 1;
10 /// <summary>
11 /// 当前页码
12 /// </summary>
13 public virtual int PageIndex
14 {
15 get { return m_pageIndex; }
16 set { m_pageIndex = value; }
17 }
18 /// <summary>
19 /// 关联的数据源
20 /// </summary>
21 public virtual List<object> DataSource { get; set; }
22 public virtual event PageControlEventHandler ShowSourceChanged;
23 private int m_pageSize = 1;
24 /// <summary>
25 /// 每页显示数量
26 /// </summary>
27 [Description("每页显示数量"), Category("自定义")]
28 public virtual int PageSize
29 {
30 get { return m_pageSize; }
31 set { m_pageSize = value; }
32 }
33 private int startIndex = 0;
34 /// <summary>
35 /// 开始的下标
36 /// </summary>
37 [Description("开始的下标"), Category("自定义")]
38 public virtual int StartIndex
39 {
40 get { return startIndex; }
41 set
42 {
43 startIndex = value;
44 if (startIndex <= 0)
45 startIndex = 0;
46 }
47 }
然后定义虚函数,并做一些默认实现
/// <summary>
/// 第一页
/// </summary>
public virtual void FirstPage()
{
if (DataSource == null)
return;
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 上一页
/// </summary>
public virtual void PreviousPage()
{
if (DataSource == null)
return;
if (startIndex == 0)
return;
startIndex -= m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 下一页
/// </summary>
public virtual void NextPage()
{
if (DataSource == null)
return;
if (startIndex + m_pageSize >= DataSource.Count)
{
return;
}
startIndex += m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 最后一页
/// </summary>
public virtual void EndPage()
{
if (DataSource == null)
return;
startIndex = DataSource.Count - m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 刷新数据
/// </summary>
public virtual void Reload()
{
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns></returns>
public virtual List<object> GetCurrentSource()
{
if (DataSource == null)
return null;
int intShowCount = m_pageSize;
if (intShowCount + startIndex > DataSource.Count)
intShowCount = DataSource.Count - startIndex;
object[] objs = new object[intShowCount];
DataSource.CopyTo(startIndex, objs, 0, intShowCount);
var lst = objs.ToList();
bool blnLeft = false;
bool blnRight = false;
if (lst.Count > 0)
{
if (DataSource.IndexOf(lst[0]) > 0)
{
blnLeft = true;
}
else
{
blnLeft = false;
}
if (DataSource.IndexOf(lst[lst.Count - 1]) >= DataSource.Count - 1)
{
blnRight = false;
}
else
{
blnRight = true;
}
}
ShowBtn(blnLeft, blnRight);
return lst;
}
/// <summary>
/// 控制按钮显示
/// </summary>
/// <param name="blnLeftBtn">是否显示上一页,第一页</param>
/// <param name="blnRightBtn">是否显示下一页,最后一页</param>
protected virtual void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
{ }
如此基类就完成了,看下完整代码
1 // 版权所有 黄正辉 交流群:568015492 QQ:623128629
2 // 文件名称:UCPagerControlBase.cs
3 // 创建日期:2019-08-15 16:00:41
4 // 功能描述:PageControl
5 // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
6 using System;
7 using System.Collections.Generic;
8 using System.ComponentModel;
9 using System.Drawing;
10 using System.Data;
11 using System.Linq;
12 using System.Text;
13 using System.Windows.Forms;
14
15 namespace HZH_Controls.Controls
16 {
17 [ToolboxItem(false)]
18 public class UCPagerControlBase : UserControl, IPageControl
19 {
20 #region 构造
21 /// <summary>
22 /// 必需的设计器变量。
23 /// </summary>
24 private System.ComponentModel.IContainer components = null;
25
26 /// <summary>
27 /// 清理所有正在使用的资源。
28 /// </summary>
29 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
30 protected override void Dispose(bool disposing)
31 {
32 if (disposing && (components != null))
33 {
34 components.Dispose();
35 }
36 base.Dispose(disposing);
37 }
38
39 #region 组件设计器生成的代码
40
41 /// <summary>
42 /// 设计器支持所需的方法 - 不要
43 /// 使用代码编辑器修改此方法的内容。
44 /// </summary>
45 private void InitializeComponent()
46 {
47 this.SuspendLayout();
48 //
49 // UCPagerControlBase
50 //
51 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
52 this.Name = "UCPagerControlBase";
53 this.Size = new System.Drawing.Size(304, 58);
54 this.Load += new System.EventHandler(this.UCPagerControlBase_Load);
55 this.ResumeLayout(false);
56
57 }
58
59 #endregion
60 #endregion
61 /// <summary>
62 /// 总页数
63 /// </summary>
64 public virtual int PageCount
65 {
66 get;
67 set;
68 }
69 private int m_pageIndex = 1;
70 /// <summary>
71 /// 当前页码
72 /// </summary>
73 public virtual int PageIndex
74 {
75 get { return m_pageIndex; }
76 set { m_pageIndex = value; }
77 }
78 /// <summary>
79 /// 关联的数据源
80 /// </summary>
81 public virtual List<object> DataSource { get; set; }
82 public virtual event PageControlEventHandler ShowSourceChanged;
83 private int m_pageSize = 1;
84 /// <summary>
85 /// 每页显示数量
86 /// </summary>
87 [Description("每页显示数量"), Category("自定义")]
88 public virtual int PageSize
89 {
90 get { return m_pageSize; }
91 set { m_pageSize = value; }
92 }
93 private int startIndex = 0;
94 /// <summary>
95 /// 开始的下标
96 /// </summary>
97 [Description("开始的下标"), Category("自定义")]
98 public virtual int StartIndex
99 {
100 get { return startIndex; }
101 set
102 {
103 startIndex = value;
104 if (startIndex <= 0)
105 startIndex = 0;
106 }
107 }
108
109 public UCPagerControlBase()
110 {
111 InitializeComponent();
112 }
113
114 private void UCPagerControlBase_Load(object sender, EventArgs e)
115 {
116 if (DataSource == null)
117 ShowBtn(false, false);
118 else
119 {
120 ShowBtn(false, DataSource.Count > PageSize);
121 }
122 }
123 /// <summary>
124 /// 第一页
125 /// </summary>
126 public virtual void FirstPage()
127 {
128 if (DataSource == null)
129 return;
130 startIndex = 0;
131 var s = GetCurrentSource();
132
133 if (ShowSourceChanged != null)
134 {
135 ShowSourceChanged(s);
136 }
137 }
138 /// <summary>
139 /// 上一页
140 /// </summary>
141 public virtual void PreviousPage()
142 {
143 if (DataSource == null)
144 return;
145 if (startIndex == 0)
146 return;
147 startIndex -= m_pageSize;
148 if (startIndex < 0)
149 startIndex = 0;
150 var s = GetCurrentSource();
151
152 if (ShowSourceChanged != null)
153 {
154 ShowSourceChanged(s);
155 }
156 }
157 /// <summary>
158 /// 下一页
159 /// </summary>
160 public virtual void NextPage()
161 {
162 if (DataSource == null)
163 return;
164 if (startIndex + m_pageSize >= DataSource.Count)
165 {
166 return;
167 }
168 startIndex += m_pageSize;
169 if (startIndex < 0)
170 startIndex = 0;
171 var s = GetCurrentSource();
172
173 if (ShowSourceChanged != null)
174 {
175 ShowSourceChanged(s);
176 }
177 }
178 /// <summary>
179 /// 最后一页
180 /// </summary>
181 public virtual void EndPage()
182 {
183 if (DataSource == null)
184 return;
185 startIndex = DataSource.Count - m_pageSize;
186 if (startIndex < 0)
187 startIndex = 0;
188 var s = GetCurrentSource();
189
190 if (ShowSourceChanged != null)
191 {
192 ShowSourceChanged(s);
193 }
194 }
195 /// <summary>
196 /// 刷新数据
197 /// </summary>
198 public virtual void Reload()
199 {
200 var s = GetCurrentSource();
201 if (ShowSourceChanged != null)
202 {
203 ShowSourceChanged(s);
204 }
205 }
206 /// <summary>
207 /// 获取当前页数据
208 /// </summary>
209 /// <returns></returns>
210 public virtual List<object> GetCurrentSource()
211 {
212 if (DataSource == null)
213 return null;
214 int intShowCount = m_pageSize;
215 if (intShowCount + startIndex > DataSource.Count)
216 intShowCount = DataSource.Count - startIndex;
217 object[] objs = new object[intShowCount];
218 DataSource.CopyTo(startIndex, objs, 0, intShowCount);
219 var lst = objs.ToList();
220
221 bool blnLeft = false;
222 bool blnRight = false;
223 if (lst.Count > 0)
224 {
225 if (DataSource.IndexOf(lst[0]) > 0)
226 {
227 blnLeft = true;
228 }
229 else
230 {
231 blnLeft = false;
232 }
233 if (DataSource.IndexOf(lst[lst.Count - 1]) >= DataSource.Count - 1)
234 {
235 blnRight = false;
236 }
237 else
238 {
239 blnRight = true;
240 }
241 }
242 ShowBtn(blnLeft, blnRight);
243 return lst;
244 }
245
246 /// <summary>
247 /// 控制按钮显示
248 /// </summary>
249 /// <param name="blnLeftBtn">是否显示上一页,第一页</param>
250 /// <param name="blnRightBtn">是否显示下一页,最后一页</param>
251 protected virtual void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
252 { }
253 }
254 }
接下来就是具体的实现分页控件了,我们将实现2种不同样式的分页控件以适应不通的场景,
第一种
添加用户控件UCPagerControl,继承UCPagerControlBase
重新基类的部分函数
1 private void panel1_MouseDown(object sender, MouseEventArgs e)
2 {
3 PreviousPage();
4 }
5
6 private void panel2_MouseDown(object sender, MouseEventArgs e)
7 {
8 NextPage();
9 }
10
11 private void panel3_MouseDown(object sender, MouseEventArgs e)
12 {
13 FirstPage();
14 }
15
16 private void panel4_MouseDown(object sender, MouseEventArgs e)
17 {
18 EndPage();
19 }
20
21 protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
22 {
23 panel1.Visible = panel3.Visible = blnLeftBtn;
24 panel2.Visible = panel4.Visible = blnRightBtn;
25 }
完成,是不是很简单,看下全部代码
1 // 版权所有 黄正辉 交流群:568015492 QQ:623128629
2 // 文件名称:UCPagerControl.cs
3 // 创建日期:2019-08-15 16:00:32
4 // 功能描述:PageControl
5 // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
6 using System;
7 using System.Collections.Generic;
8 using System.ComponentModel;
9 using System.Drawing;
10 using System.Data;
11 using System.Linq;
12 using System.Text;
13 using System.Windows.Forms;
14
15 namespace HZH_Controls.Controls
16 {
17 [ToolboxItem(true)]
18 public partial class UCPagerControl : UCPagerControlBase
19 {
20 public UCPagerControl()
21 {
22 InitializeComponent();
23 }
24
25 private void panel1_MouseDown(object sender, MouseEventArgs e)
26 {
27 PreviousPage();
28 }
29
30 private void panel2_MouseDown(object sender, MouseEventArgs e)
31 {
32 NextPage();
33 }
34
35 private void panel3_MouseDown(object sender, MouseEventArgs e)
36 {
37 FirstPage();
38 }
39
40 private void panel4_MouseDown(object sender, MouseEventArgs e)
41 {
42 EndPage();
43 }
44
45 protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
46 {
47 panel1.Visible = panel3.Visible = blnLeftBtn;
48 panel2.Visible = panel4.Visible = blnRightBtn;
49 }
50 }
51 }
1 namespace HZH_Controls.Controls
2 {
3 partial class UCPagerControl
4 {
5 /// <summary>
6 /// 必需的设计器变量。
7 /// </summary>
8 private System.ComponentModel.IContainer components = null;
9
10 /// <summary>
11 /// 清理所有正在使用的资源。
12 /// </summary>
13 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
14 protected override void Dispose(bool disposing)
15 {
16 if (disposing && (components != null))
17 {
18 components.Dispose();
19 }
20 base.Dispose(disposing);
21 }
22
23 #region 组件设计器生成的代码
24
25 /// <summary>
26 /// 设计器支持所需的方法 - 不要
27 /// 使用代码编辑器修改此方法的内容。
28 /// </summary>
29 private void InitializeComponent()
30 {
31 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
32 this.panel4 = new System.Windows.Forms.Panel();
33 this.panel3 = new System.Windows.Forms.Panel();
34 this.panel2 = new System.Windows.Forms.Panel();
35 this.panel1 = new System.Windows.Forms.Panel();
36 this.tableLayoutPanel1.SuspendLayout();
37 this.SuspendLayout();
38 //
39 // tableLayoutPanel1
40 //
41 this.tableLayoutPanel1.ColumnCount = 4;
42 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
43 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
44 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
45 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
46 this.tableLayoutPanel1.Controls.Add(this.panel4, 3, 0);
47 this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0);
48 this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0);
49 this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
50 this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
51 this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
52 this.tableLayoutPanel1.Name = "tableLayoutPanel1";
53 this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
54 this.tableLayoutPanel1.RowCount = 1;
55 this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
56 this.tableLayoutPanel1.Size = new System.Drawing.Size(304, 58);
57 this.tableLayoutPanel1.TabIndex = 1;
58 //
59 // panel4
60 //
61 this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end;
62 this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
63 this.panel4.Location = new System.Drawing.Point(228, 6);
64 this.panel4.Name = "panel4";
65 this.panel4.Size = new System.Drawing.Size(68, 46);
66 this.panel4.TabIndex = 3;
67 this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown);
68 //
69 // panel3
70 //
71 this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first;
72 this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
73 this.panel3.Location = new System.Drawing.Point(6, 6);
74 this.panel3.Name = "panel3";
75 this.panel3.Size = new System.Drawing.Size(68, 46);
76 this.panel3.TabIndex = 2;
77 this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown);
78 //
79 // panel2
80 //
81 this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right;
82 this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
83 this.panel2.Location = new System.Drawing.Point(154, 6);
84 this.panel2.Name = "panel2";
85 this.panel2.Size = new System.Drawing.Size(68, 46);
86 this.panel2.TabIndex = 1;
87 this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown);
88 //
89 // panel1
90 //
91 this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left;
92 this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
93 this.panel1.Location = new System.Drawing.Point(80, 6);
94 this.panel1.Name = "panel1";
95 this.panel1.Size = new System.Drawing.Size(68, 46);
96 this.panel1.TabIndex = 0;
97 this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
98 //
99 // UCPagerControl
100 //
101 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
102 this.Controls.Add(this.tableLayoutPanel1);
103 this.Name = "UCPagerControl";
104 this.tableLayoutPanel1.ResumeLayout(false);
105 this.ResumeLayout(false);
106
107 }
108
109 #endregion
110
111 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
112 private System.Windows.Forms.Panel panel4;
113 private System.Windows.Forms.Panel panel3;
114 private System.Windows.Forms.Panel panel2;
115 private System.Windows.Forms.Panel panel1;
116 }
117 }
第二种
这种和第一种的唯一区别就是页面计算生成的部分了
添加一个用户控件UCPagerControl2,继承UCPagerControlBase
属性如下
1 public override event PageControlEventHandler ShowSourceChanged;
2
3 private List<object> m_dataSource;
4 public override List<object> DataSource
5 {
6 get
7 {
8 return m_dataSource;
9 }
10 set
11 {
12 m_dataSource = value;
13 if (m_dataSource == null)
14 m_dataSource = new List<object>();
15 ResetPageCount();
16 }
17 }
18 private int m_intPageSize = 0;
19 public override int PageSize
20 {
21 get
22 {
23 return m_intPageSize;
24 }
25 set
26 {
27 m_intPageSize = value;
28 ResetPageCount();
29 }
30 }
其他更多的属性直接用基类的就可以
重写基类函数
1 public override void FirstPage()
2 {
3 if (PageIndex == 1)
4 return;
5 PageIndex = 1;
6 StartIndex = (PageIndex - 1) * PageSize;
7 ReloadPage();
8 var s = GetCurrentSource();
9 if (ShowSourceChanged != null)
10 {
11 ShowSourceChanged(s);
12 }
13 }
14
15 public override void PreviousPage()
16 {
17 if (PageIndex <= 1)
18 {
19 return;
20 }
21 PageIndex--;
22
23 StartIndex = (PageIndex - 1) * PageSize;
24 ReloadPage();
25 var s = GetCurrentSource();
26 if (ShowSourceChanged != null)
27 {
28 ShowSourceChanged(s);
29 }
30 }
31
32 public override void NextPage()
33 {
34 if (PageIndex >= PageCount)
35 {
36 return;
37 }
38 PageIndex++;
39 StartIndex = (PageIndex - 1) * PageSize;
40 ReloadPage();
41 var s = GetCurrentSource();
42 if (ShowSourceChanged != null)
43 {
44 ShowSourceChanged(s);
45 }
46 }
47
48 public override void EndPage()
49 {
50 if (PageIndex == PageCount)
51 return;
52 PageIndex = PageCount;
53 StartIndex = (PageIndex - 1) * PageSize;
54 ReloadPage();
55 var s = GetCurrentSource();
56 if (ShowSourceChanged != null)
57 {
58 ShowSourceChanged(s);
59 }
60 }
61
62 protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
63 {
64 btnFirst.Enabled = btnPrevious.Enabled = blnLeftBtn;
65 btnNext.Enabled = btnEnd.Enabled = blnRightBtn;
66 }
一个重置总页数的函数
1 private void ResetPageCount()
2 {
3 if (PageSize > 0)
4 {
5 PageCount = m_dataSource.Count / m_intPageSize + (m_dataSource.Count % m_intPageSize > 0 ? 1 : 0);
6 }
7 txtPage.MaxValue = PageCount;
8 txtPage.MinValue = 1;
9 ReloadPage();
10 }
一个重置计算当前页码列表的函数
private void ReloadPage()
{
try
{
ControlHelper.FreezeControl(tableLayoutPanel1, true);
List<int> lst = new List<int>();
if (PageCount <= 9)
{
for (var i = 1; i <= PageCount; i++)
{
lst.Add(i);
}
}
else
{
if (this.PageIndex <= 6)
{
for (var i = 1; i <= 7; i++)
{
lst.Add(i);
}
lst.Add(-1);
lst.Add(PageCount);
}
else if (this.PageIndex > PageCount - 6)
{
lst.Add(1);
lst.Add(-1);
for (var i = PageCount - 6; i <= PageCount; i++)
{
lst.Add(i);
}
}
else
{
lst.Add(1);
lst.Add(-1);
var begin = PageIndex - 2;
var end = PageIndex + 2;
if (end > PageCount)
{
end = PageCount;
begin = end - 4;
if (PageIndex - begin < 2)
{
begin = begin - 1;
}
}
else if (end + 1 == PageCount)
{
end = PageCount;
}
for (var i = begin; i <= end; i++)
{
lst.Add(i);
}
if (end != PageCount)
{
lst.Add(-1);
lst.Add(PageCount);
}
}
}
for (int i = 0; i < 9; i++)
{
UCBtnExt c = (UCBtnExt)this.tableLayoutPanel1.Controls.Find("p" + (i + 1), false)[0];
if (i >= lst.Count)
{
c.Visible = false;
}
else
{
if (lst[i] == -1)
{
c.BtnText = "...";
c.Enabled = false;
}
else
{
c.BtnText = lst[i].ToString();
c.Enabled = true;
}
c.Visible = true;
if (lst[i] == PageIndex)
{
c.RectColor = Color.FromArgb(255, 77, 59);
}
else
{
c.RectColor = Color.FromArgb(223, 223, 223);
}
}
}
ShowBtn(PageIndex > 1, PageIndex < PageCount);
}
finally
{
ControlHelper.FreezeControl(tableLayoutPanel1, false);
}
}
跳转页面
1 private void page_BtnClick(object sender, EventArgs e)
2 {
3 PageIndex = (sender as UCBtnExt).BtnText.ToInt();
4 StartIndex = (PageIndex - 1) * PageSize;
5 ReloadPage();
6 var s = GetCurrentSource();
7
8 if (ShowSourceChanged != null)
9 {
10 ShowSourceChanged(s);
11 }
12 }
13 private void btnFirst_BtnClick(object sender, EventArgs e)
14 {
15 FirstPage();
16 }
17
18 private void btnPrevious_BtnClick(object sender, EventArgs e)
19 {
20 PreviousPage();
21 }
22
23 private void btnNext_BtnClick(object sender, EventArgs e)
24 {
25 NextPage();
26 }
27
28 private void btnEnd_BtnClick(object sender, EventArgs e)
29 {
30 EndPage();
31 }
32
33 private void btnToPage_BtnClick(object sender, EventArgs e)
34 {
35 if (!string.IsNullOrEmpty(txtPage.InputText))
36 {
37 PageIndex = txtPage.InputText.ToInt();
38 StartIndex = (PageIndex - 1) * PageSize;
39 ReloadPage();
40 var s = GetCurrentSource();
41 if (ShowSourceChanged != null)
42 {
43 ShowSourceChanged(s);
44 }
45 }
46 }
至此完成所有逻辑,看下完整代码
1 // 版权所有 黄正辉 交流群:568015492 QQ:623128629
2 // 文件名称:UCPagerControl2.cs
3 // 创建日期:2019-08-15 16:00:37
4 // 功能描述:PageControl
5 // 项目地址:https://gitee.com/kwwwvagaa/net_winform_custom_control
6 using System;
7 using System.Collections.Generic;
8 using System.ComponentModel;
9 using System.Drawing;
10 using System.Data;
11 using System.Linq;
12 using System.Text;
13 using System.Windows.Forms;
14
15 namespace HZH_Controls.Controls.List
16 {
17 [ToolboxItem(true)]
18 public partial class UCPagerControl2 : UCPagerControlBase
19 {
20 public UCPagerControl2()
21 {
22 InitializeComponent();
23 txtPage.txtInput.KeyDown += txtInput_KeyDown;
24 }
25
26 void txtInput_KeyDown(object sender, KeyEventArgs e)
27 {
28 if (e.KeyCode == Keys.Enter)
29 {
30 btnToPage_BtnClick(null, null);
31 txtPage.InputText = "";
32 }
33 }
34
35 public override event PageControlEventHandler ShowSourceChanged;
36
37 private List<object> m_dataSource;
38 public override List<object> DataSource
39 {
40 get
41 {
42 return m_dataSource;
43 }
44 set
45 {
46 m_dataSource = value;
47 if (m_dataSource == null)
48 m_dataSource = new List<object>();
49 ResetPageCount();
50 }
51 }
52 private int m_intPageSize = 0;
53 public override int PageSize
54 {
55 get
56 {
57 return m_intPageSize;
58 }
59 set
60 {
61 m_intPageSize = value;
62 ResetPageCount();
63 }
64 }
65
66 public override void FirstPage()
67 {
68 if (PageIndex == 1)
69 return;
70 PageIndex = 1;
71 StartIndex = (PageIndex - 1) * PageSize;
72 ReloadPage();
73 var s = GetCurrentSource();
74 if (ShowSourceChanged != null)
75 {
76 ShowSourceChanged(s);
77 }
78 }
79
80 public override void PreviousPage()
81 {
82 if (PageIndex <= 1)
83 {
84 return;
85 }
86 PageIndex--;
87
88 StartIndex = (PageIndex - 1) * PageSize;
89 ReloadPage();
90 var s = GetCurrentSource();
91 if (ShowSourceChanged != null)
92 {
93 ShowSourceChanged(s);
94 }
95 }
96
97 public override void NextPage()
98 {
99 if (PageIndex >= PageCount)
100 {
101 return;
102 }
103 PageIndex++;
104 StartIndex = (PageIndex - 1) * PageSize;
105 ReloadPage();
106 var s = GetCurrentSource();
107 if (ShowSourceChanged != null)
108 {
109 ShowSourceChanged(s);
110 }
111 }
112
113 public override void EndPage()
114 {
115 if (PageIndex == PageCount)
116 return;
117 PageIndex = PageCount;
118 StartIndex = (PageIndex - 1) * PageSize;
119 ReloadPage();
120 var s = GetCurrentSource();
121 if (ShowSourceChanged != null)
122 {
123 ShowSourceChanged(s);
124 }
125 }
126
127 private void ResetPageCount()
128 {
129 if (PageSize > 0)
130 {
131 PageCount = m_dataSource.Count / m_intPageSize + (m_dataSource.Count % m_intPageSize > 0 ? 1 : 0);
132 }
133 txtPage.MaxValue = PageCount;
134 txtPage.MinValue = 1;
135 ReloadPage();
136 }
137
138 private void ReloadPage()
139 {
140 try
141 {
142 ControlHelper.FreezeControl(tableLayoutPanel1, true);
143 List<int> lst = new List<int>();
144
145 if (PageCount <= 9)
146 {
147 for (var i = 1; i <= PageCount; i++)
148 {
149 lst.Add(i);
150 }
151 }
152 else
153 {
154 if (this.PageIndex <= 6)
155 {
156 for (var i = 1; i <= 7; i++)
157 {
158 lst.Add(i);
159 }
160 lst.Add(-1);
161 lst.Add(PageCount);
162 }
163 else if (this.PageIndex > PageCount - 6)
164 {
165 lst.Add(1);
166 lst.Add(-1);
167 for (var i = PageCount - 6; i <= PageCount; i++)
168 {
169 lst.Add(i);
170 }
171 }
172 else
173 {
174 lst.Add(1);
175 lst.Add(-1);
176 var begin = PageIndex - 2;
177 var end = PageIndex + 2;
178 if (end > PageCount)
179 {
180 end = PageCount;
181 begin = end - 4;
182 if (PageIndex - begin < 2)
183 {
184 begin = begin - 1;
185 }
186 }
187 else if (end + 1 == PageCount)
188 {
189 end = PageCount;
190 }
191 for (var i = begin; i <= end; i++)
192 {
193 lst.Add(i);
194 }
195 if (end != PageCount)
196 {
197 lst.Add(-1);
198 lst.Add(PageCount);
199 }
200 }
201 }
202
203 for (int i = 0; i < 9; i++)
204 {
205 UCBtnExt c = (UCBtnExt)this.tableLayoutPanel1.Controls.Find("p" + (i + 1), false)[0];
206 if (i >= lst.Count)
207 {
208 c.Visible = false;
209 }
210 else
211 {
212 if (lst[i] == -1)
213 {
214 c.BtnText = "...";
215 c.Enabled = false;
216 }
217 else
218 {
219 c.BtnText = lst[i].ToString();
220 c.Enabled = true;
221 }
222 c.Visible = true;
223 if (lst[i] == PageIndex)
224 {
225 c.RectColor = Color.FromArgb(255, 77, 59);
226 }
227 else
228 {
229 c.RectColor = Color.FromArgb(223, 223, 223);
230 }
231 }
232 }
233 ShowBtn(PageIndex > 1, PageIndex < PageCount);
234 }
235 finally
236 {
237 ControlHelper.FreezeControl(tableLayoutPanel1, false);
238 }
239 }
240
241 private void page_BtnClick(object sender, EventArgs e)
242 {
243 PageIndex = (sender as UCBtnExt).BtnText.ToInt();
244 StartIndex = (PageIndex - 1) * PageSize;
245 ReloadPage();
246 var s = GetCurrentSource();
247
248 if (ShowSourceChanged != null)
249 {
250 ShowSourceChanged(s);
251 }
252 }
253
254 protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
255 {
256 btnFirst.Enabled = btnPrevious.Enabled = blnLeftBtn;
257 btnNext.Enabled = btnEnd.Enabled = blnRightBtn;
258 }
259
260 private void btnFirst_BtnClick(object sender, EventArgs e)
261 {
262 FirstPage();
263 }
264
265 private void btnPrevious_BtnClick(object sender, EventArgs e)
266 {
267 PreviousPage();
268 }
269
270 private void btnNext_BtnClick(object sender, EventArgs e)
271 {
272 NextPage();
273 }
274
275 private void btnEnd_BtnClick(object sender, EventArgs e)
276 {
277 EndPage();
278 }
279
280 private void btnToPage_BtnClick(object sender, EventArgs e)
281 {
282 if (!string.IsNullOrEmpty(txtPage.InputText))
283 {
284 PageIndex = txtPage.InputText.ToInt();
285 StartIndex = (PageIndex - 1) * PageSize;
286 ReloadPage();
287 var s = GetCurrentSource();
288 if (ShowSourceChanged != null)
289 {
290 ShowSourceChanged(s);
291 }
292 }
293 }
294
295 }
296 }
1 namespace HZH_Controls.Controls.List
2 {
3 partial class UCPagerControl2
4 {
5 /// <summary>
6 /// 必需的设计器变量。
7 /// </summary>
8 private System.ComponentModel.IContainer components = null;
9
10 /// <summary>
11 /// 清理所有正在使用的资源。
12 /// </summary>
13 /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
14 protected override void Dispose(bool disposing)
15 {
16 if (disposing && (components != null))
17 {
18 components.Dispose();
19 }
20 base.Dispose(disposing);
21 }
22
23 #region 组件设计器生成的代码
24
25 /// <summary>
26 /// 设计器支持所需的方法 - 不要
27 /// 使用代码编辑器修改此方法的内容。
28 /// </summary>
29 private void InitializeComponent()
30 {
31 this.btnFirst = new HZH_Controls.Controls.UCBtnExt();
32 this.btnPrevious = new HZH_Controls.Controls.UCBtnExt();
33 this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
34 this.p9 = new HZH_Controls.Controls.UCBtnExt();
35 this.p1 = new HZH_Controls.Controls.UCBtnExt();
36 this.btnToPage = new HZH_Controls.Controls.UCBtnExt();
37 this.btnEnd = new HZH_Controls.Controls.UCBtnExt();
38 this.btnNext = new HZH_Controls.Controls.UCBtnExt();
39 this.p8 = new HZH_Controls.Controls.UCBtnExt();
40 this.p7 = new HZH_Controls.Controls.UCBtnExt();
41 this.p6 = new HZH_Controls.Controls.UCBtnExt();
42 this.p5 = new HZH_Controls.Controls.UCBtnExt();
43 this.p4 = new HZH_Controls.Controls.UCBtnExt();
44 this.p3 = new HZH_Controls.Controls.UCBtnExt();
45 this.p2 = new HZH_Controls.Controls.UCBtnExt();
46 this.txtPage = new HZH_Controls.Controls.UCTextBoxEx();
47 this.tableLayoutPanel1.SuspendLayout();
48 this.SuspendLayout();
49 //
50 // btnFirst
51 //
52 this.btnFirst.BackColor = System.Drawing.Color.White;
53 this.btnFirst.BtnBackColor = System.Drawing.Color.White;
54 this.btnFirst.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
55 this.btnFirst.BtnForeColor = System.Drawing.Color.Gray;
56 this.btnFirst.BtnText = "<<";
57 this.btnFirst.ConerRadius = 5;
58 this.btnFirst.Cursor = System.Windows.Forms.Cursors.Hand;
59 this.btnFirst.Dock = System.Windows.Forms.DockStyle.Fill;
60 this.btnFirst.FillColor = System.Drawing.Color.White;
61 this.btnFirst.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
62 this.btnFirst.IsRadius = true;
63 this.btnFirst.IsShowRect = true;
64 this.btnFirst.IsShowTips = false;
65 this.btnFirst.Location = new System.Drawing.Point(5, 5);
66 this.btnFirst.Margin = new System.Windows.Forms.Padding(5);
67 this.btnFirst.Name = "btnFirst";
68 this.btnFirst.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
69 this.btnFirst.RectWidth = 1;
70 this.btnFirst.Size = new System.Drawing.Size(30, 30);
71 this.btnFirst.TabIndex = 0;
72 this.btnFirst.TabStop = false;
73 this.btnFirst.TipsText = "";
74 this.btnFirst.BtnClick += new System.EventHandler(this.btnFirst_BtnClick);
75 //
76 // btnPrevious
77 //
78 this.btnPrevious.BackColor = System.Drawing.Color.White;
79 this.btnPrevious.BtnBackColor = System.Drawing.Color.White;
80 this.btnPrevious.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
81 this.btnPrevious.BtnForeColor = System.Drawing.Color.Gray;
82 this.btnPrevious.BtnText = "<";
83 this.btnPrevious.ConerRadius = 5;
84 this.btnPrevious.Cursor = System.Windows.Forms.Cursors.Hand;
85 this.btnPrevious.Dock = System.Windows.Forms.DockStyle.Fill;
86 this.btnPrevious.FillColor = System.Drawing.Color.White;
87 this.btnPrevious.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
88 this.btnPrevious.IsRadius = true;
89 this.btnPrevious.IsShowRect = true;
90 this.btnPrevious.IsShowTips = false;
91 this.btnPrevious.Location = new System.Drawing.Point(45, 5);
92 this.btnPrevious.Margin = new System.Windows.Forms.Padding(5);
93 this.btnPrevious.Name = "btnPrevious";
94 this.btnPrevious.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
95 this.btnPrevious.RectWidth = 1;
96 this.btnPrevious.Size = new System.Drawing.Size(30, 30);
97 this.btnPrevious.TabIndex = 1;
98 this.btnPrevious.TabStop = false;
99 this.btnPrevious.TipsText = "";
100 this.btnPrevious.BtnClick += new System.EventHandler(this.btnPrevious_BtnClick);
101 //
102 // tableLayoutPanel1
103 //
104 this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
105 this.tableLayoutPanel1.ColumnCount = 15;
106 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
107 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
108 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
109 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
110 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
111 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
112 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
113 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
114 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
115 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
116 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
117 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
118 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
119 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 70F));
120 this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 70F));
121 this.tableLayoutPanel1.Controls.Add(this.p9, 10, 0);
122 this.tableLayoutPanel1.Controls.Add(this.p1, 2, 0);
123 this.tableLayoutPanel1.Controls.Add(this.btnToPage, 14, 0);
124 this.tableLayoutPanel1.Controls.Add(this.btnEnd, 12, 0);
125 this.tableLayoutPanel1.Controls.Add(this.btnNext, 11, 0);
126 this.tableLayoutPanel1.Controls.Add(this.p8, 9, 0);
127 this.tableLayoutPanel1.Controls.Add(this.p7, 8, 0);
128 this.tableLayoutPanel1.Controls.Add(this.p6, 7, 0);
129 this.tableLayoutPanel1.Controls.Add(this.p5, 6, 0);
130 this.tableLayoutPanel1.Controls.Add(this.p4, 5, 0);
131 this.tableLayoutPanel1.Controls.Add(this.p3, 4, 0);
132 this.tableLayoutPanel1.Controls.Add(this.p2, 3, 0);
133 this.tableLayoutPanel1.Controls.Add(this.btnPrevious, 1, 0);
134 this.tableLayoutPanel1.Controls.Add(this.btnFirst, 0, 0);
135 this.tableLayoutPanel1.Controls.Add(this.txtPage, 13, 0);
136 this.tableLayoutPanel1.Location = new System.Drawing.Point(129, 0);
137 this.tableLayoutPanel1.Name = "tableLayoutPanel1";
138 this.tableLayoutPanel1.RowCount = 1;
139 this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
140 this.tableLayoutPanel1.Size = new System.Drawing.Size(662, 40);
141 this.tableLayoutPanel1.TabIndex = 1;
142 //
143 // p9
144 //
145 this.p9.BackColor = System.Drawing.Color.White;
146 this.p9.BtnBackColor = System.Drawing.Color.White;
147 this.p9.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
148 this.p9.BtnForeColor = System.Drawing.Color.Gray;
149 this.p9.BtnText = "9";
150 this.p9.ConerRadius = 5;
151 this.p9.Cursor = System.Windows.Forms.Cursors.Hand;
152 this.p9.Dock = System.Windows.Forms.DockStyle.Fill;
153 this.p9.FillColor = System.Drawing.Color.White;
154 this.p9.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
155 this.p9.IsRadius = true;
156 this.p9.IsShowRect = true;
157 this.p9.IsShowTips = false;
158 this.p9.Location = new System.Drawing.Point(402, 5);
159 this.p9.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
160 this.p9.Name = "p9";
161 this.p9.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
162 this.p9.RectWidth = 1;
163 this.p9.Size = new System.Drawing.Size(36, 30);
164 this.p9.TabIndex = 17;
165 this.p9.TabStop = false;
166 this.p9.TipsText = "";
167 this.p9.BtnClick += new System.EventHandler(this.page_BtnClick);
168 //
169 // p1
170 //
171 this.p1.BackColor = System.Drawing.Color.White;
172 this.p1.BtnBackColor = System.Drawing.Color.White;
173 this.p1.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
174 this.p1.BtnForeColor = System.Drawing.Color.Gray;
175 this.p1.BtnText = "1";
176 this.p1.ConerRadius = 5;
177 this.p1.Cursor = System.Windows.Forms.Cursors.Hand;
178 this.p1.Dock = System.Windows.Forms.DockStyle.Fill;
179 this.p1.FillColor = System.Drawing.Color.White;
180 this.p1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
181 this.p1.IsRadius = true;
182 this.p1.IsShowRect = true;
183 this.p1.IsShowTips = false;
184 this.p1.Location = new System.Drawing.Point(82, 5);
185 this.p1.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
186 this.p1.Name = "p1";
187 this.p1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
188 this.p1.RectWidth = 1;
189 this.p1.Size = new System.Drawing.Size(36, 30);
190 this.p1.TabIndex = 16;
191 this.p1.TabStop = false;
192 this.p1.TipsText = "";
193 this.p1.BtnClick += new System.EventHandler(this.page_BtnClick);
194 //
195 // btnToPage
196 //
197 this.btnToPage.BackColor = System.Drawing.Color.White;
198 this.btnToPage.BtnBackColor = System.Drawing.Color.White;
199 this.btnToPage.BtnFont = new System.Drawing.Font("微软雅黑", 11F);
200 this.btnToPage.BtnForeColor = System.Drawing.Color.Gray;
201 this.btnToPage.BtnText = "跳转";
202 this.btnToPage.ConerRadius = 5;
203 this.btnToPage.Cursor = System.Windows.Forms.Cursors.Hand;
204 this.btnToPage.Dock = System.Windows.Forms.DockStyle.Fill;
205 this.btnToPage.FillColor = System.Drawing.Color.White;
206 this.btnToPage.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
207 this.btnToPage.IsRadius = true;
208 this.btnToPage.IsShowRect = true;
209 this.btnToPage.IsShowTips = false;
210 this.btnToPage.Location = new System.Drawing.Point(595, 5);
211 this.btnToPage.Margin = new System.Windows.Forms.Padding(5);
212 this.btnToPage.Name = "btnToPage";
213 this.btnToPage.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
214 this.btnToPage.RectWidth = 1;
215 this.btnToPage.Size = new System.Drawing.Size(62, 30);
216 this.btnToPage.TabIndex = 15;
217 this.btnToPage.TabStop = false;
218 this.btnToPage.TipsText = "";
219 this.btnToPage.BtnClick += new System.EventHandler(this.btnToPage_BtnClick);
220 //
221 // btnEnd
222 //
223 this.btnEnd.BackColor = System.Drawing.Color.White;
224 this.btnEnd.BtnBackColor = System.Drawing.Color.White;
225 this.btnEnd.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
226 this.btnEnd.BtnForeColor = System.Drawing.Color.Gray;
227 this.btnEnd.BtnText = ">>";
228 this.btnEnd.ConerRadius = 5;
229 this.btnEnd.Cursor = System.Windows.Forms.Cursors.Hand;
230 this.btnEnd.Dock = System.Windows.Forms.DockStyle.Fill;
231 this.btnEnd.FillColor = System.Drawing.Color.White;
232 this.btnEnd.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
233 this.btnEnd.IsRadius = true;
234 this.btnEnd.IsShowRect = true;
235 this.btnEnd.IsShowTips = false;
236 this.btnEnd.Location = new System.Drawing.Point(485, 5);
237 this.btnEnd.Margin = new System.Windows.Forms.Padding(5);
238 this.btnEnd.Name = "btnEnd";
239 this.btnEnd.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
240 this.btnEnd.RectWidth = 1;
241 this.btnEnd.Size = new System.Drawing.Size(30, 30);
242 this.btnEnd.TabIndex = 13;
243 this.btnEnd.TabStop = false;
244 this.btnEnd.TipsText = "";
245 this.btnEnd.BtnClick += new System.EventHandler(this.btnEnd_BtnClick);
246 //
247 // btnNext
248 //
249 this.btnNext.BackColor = System.Drawing.Color.White;
250 this.btnNext.BtnBackColor = System.Drawing.Color.White;
251 this.btnNext.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
252 this.btnNext.BtnForeColor = System.Drawing.Color.Gray;
253 this.btnNext.BtnText = ">";
254 this.btnNext.ConerRadius = 5;
255 this.btnNext.Cursor = System.Windows.Forms.Cursors.Hand;
256 this.btnNext.Dock = System.Windows.Forms.DockStyle.Fill;
257 this.btnNext.FillColor = System.Drawing.Color.White;
258 this.btnNext.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
259 this.btnNext.IsRadius = true;
260 this.btnNext.IsShowRect = true;
261 this.btnNext.IsShowTips = false;
262 this.btnNext.Location = new System.Drawing.Point(445, 5);
263 this.btnNext.Margin = new System.Windows.Forms.Padding(5);
264 this.btnNext.Name = "btnNext";
265 this.btnNext.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
266 this.btnNext.RectWidth = 1;
267 this.btnNext.Size = new System.Drawing.Size(30, 30);
268 this.btnNext.TabIndex = 12;
269 this.btnNext.TabStop = false;
270 this.btnNext.TipsText = "";
271 this.btnNext.BtnClick += new System.EventHandler(this.btnNext_BtnClick);
272 //
273 // p8
274 //
275 this.p8.BackColor = System.Drawing.Color.White;
276 this.p8.BtnBackColor = System.Drawing.Color.White;
277 this.p8.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
278 this.p8.BtnForeColor = System.Drawing.Color.Gray;
279 this.p8.BtnText = "8";
280 this.p8.ConerRadius = 5;
281 this.p8.Cursor = System.Windows.Forms.Cursors.Hand;
282 this.p8.Dock = System.Windows.Forms.DockStyle.Fill;
283 this.p8.FillColor = System.Drawing.Color.White;
284 this.p8.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
285 this.p8.IsRadius = true;
286 this.p8.IsShowRect = true;
287 this.p8.IsShowTips = false;
288 this.p8.Location = new System.Drawing.Point(362, 5);
289 this.p8.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
290 this.p8.Name = "p8";
291 this.p8.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
292 this.p8.RectWidth = 1;
293 this.p8.Size = new System.Drawing.Size(36, 30);
294 this.p8.TabIndex = 8;
295 this.p8.TabStop = false;
296 this.p8.TipsText = "";
297 this.p8.BtnClick += new System.EventHandler(this.page_BtnClick);
298 //
299 // p7
300 //
301 this.p7.BackColor = System.Drawing.Color.White;
302 this.p7.BtnBackColor = System.Drawing.Color.White;
303 this.p7.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
304 this.p7.BtnForeColor = System.Drawing.Color.Gray;
305 this.p7.BtnText = "7";
306 this.p7.ConerRadius = 5;
307 this.p7.Cursor = System.Windows.Forms.Cursors.Hand;
308 this.p7.Dock = System.Windows.Forms.DockStyle.Fill;
309 this.p7.FillColor = System.Drawing.Color.White;
310 this.p7.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
311 this.p7.IsRadius = true;
312 this.p7.IsShowRect = true;
313 this.p7.IsShowTips = false;
314 this.p7.Location = new System.Drawing.Point(322, 5);
315 this.p7.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
316 this.p7.Name = "p7";
317 this.p7.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
318 this.p7.RectWidth = 1;
319 this.p7.Size = new System.Drawing.Size(36, 30);
320 this.p7.TabIndex = 7;
321 this.p7.TabStop = false;
322 this.p7.TipsText = "";
323 this.p7.BtnClick += new System.EventHandler(this.page_BtnClick);
324 //
325 // p6
326 //
327 this.p6.BackColor = System.Drawing.Color.White;
328 this.p6.BtnBackColor = System.Drawing.Color.White;
329 this.p6.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
330 this.p6.BtnForeColor = System.Drawing.Color.Gray;
331 this.p6.BtnText = "6";
332 this.p6.ConerRadius = 5;
333 this.p6.Cursor = System.Windows.Forms.Cursors.Hand;
334 this.p6.Dock = System.Windows.Forms.DockStyle.Fill;
335 this.p6.FillColor = System.Drawing.Color.White;
336 this.p6.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
337 this.p6.IsRadius = true;
338 this.p6.IsShowRect = true;
339 this.p6.IsShowTips = false;
340 this.p6.Location = new System.Drawing.Point(282, 5);
341 this.p6.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
342 this.p6.Name = "p6";
343 this.p6.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
344 this.p6.RectWidth = 1;
345 this.p6.Size = new System.Drawing.Size(36, 30);
346 this.p6.TabIndex = 6;
347 this.p6.TabStop = false;
348 this.p6.TipsText = "";
349 this.p6.BtnClick += new System.EventHandler(this.page_BtnClick);
350 //
351 // p5
352 //
353 this.p5.BackColor = System.Drawing.Color.White;
354 this.p5.BtnBackColor = System.Drawing.Color.White;
355 this.p5.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
356 this.p5.BtnForeColor = System.Drawing.Color.Gray;
357 this.p5.BtnText = "5";
358 this.p5.ConerRadius = 5;
359 this.p5.Cursor = System.Windows.Forms.Cursors.Hand;
360 this.p5.Dock = System.Windows.Forms.DockStyle.Fill;
361 this.p5.FillColor = System.Drawing.Color.White;
362 this.p5.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
363 this.p5.IsRadius = true;
364 this.p5.IsShowRect = true;
365 this.p5.IsShowTips = false;
366 this.p5.Location = new System.Drawing.Point(242, 5);
367 this.p5.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
368 this.p5.Name = "p5";
369 this.p5.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
370 this.p5.RectWidth = 1;
371 this.p5.Size = new System.Drawing.Size(36, 30);
372 this.p5.TabIndex = 5;
373 this.p5.TabStop = false;
374 this.p5.TipsText = "";
375 this.p5.BtnClick += new System.EventHandler(this.page_BtnClick);
376 //
377 // p4
378 //
379 this.p4.BackColor = System.Drawing.Color.White;
380 this.p4.BtnBackColor = System.Drawing.Color.White;
381 this.p4.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
382 this.p4.BtnForeColor = System.Drawing.Color.Gray;
383 this.p4.BtnText = "4";
384 this.p4.ConerRadius = 5;
385 this.p4.Cursor = System.Windows.Forms.Cursors.Hand;
386 this.p4.Dock = System.Windows.Forms.DockStyle.Fill;
387 this.p4.FillColor = System.Drawing.Color.White;
388 this.p4.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
389 this.p4.IsRadius = true;
390 this.p4.IsShowRect = true;
391 this.p4.IsShowTips = false;
392 this.p4.Location = new System.Drawing.Point(202, 5);
393 this.p4.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
394 this.p4.Name = "p4";
395 this.p4.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
396 this.p4.RectWidth = 1;
397 this.p4.Size = new System.Drawing.Size(36, 30);
398 this.p4.TabIndex = 4;
399 this.p4.TabStop = false;
400 this.p4.TipsText = "";
401 this.p4.BtnClick += new System.EventHandler(this.page_BtnClick);
402 //
403 // p3
404 //
405 this.p3.BackColor = System.Drawing.Color.White;
406 this.p3.BtnBackColor = System.Drawing.Color.White;
407 this.p3.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
408 this.p3.BtnForeColor = System.Drawing.Color.Gray;
409 this.p3.BtnText = "3";
410 this.p3.ConerRadius = 5;
411 this.p3.Cursor = System.Windows.Forms.Cursors.Hand;
412 this.p3.Dock = System.Windows.Forms.DockStyle.Fill;
413 this.p3.FillColor = System.Drawing.Color.White;
414 this.p3.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
415 this.p3.IsRadius = true;
416 this.p3.IsShowRect = true;
417 this.p3.IsShowTips = false;
418 this.p3.Location = new System.Drawing.Point(162, 5);
419 this.p3.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
420 this.p3.Name = "p3";
421 this.p3.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
422 this.p3.RectWidth = 1;
423 this.p3.Size = new System.Drawing.Size(36, 30);
424 this.p3.TabIndex = 3;
425 this.p3.TabStop = false;
426 this.p3.TipsText = "";
427 this.p3.BtnClick += new System.EventHandler(this.page_BtnClick);
428 //
429 // p2
430 //
431 this.p2.BackColor = System.Drawing.Color.White;
432 this.p2.BtnBackColor = System.Drawing.Color.White;
433 this.p2.BtnFont = new System.Drawing.Font("微软雅黑", 9F);
434 this.p2.BtnForeColor = System.Drawing.Color.Gray;
435 this.p2.BtnText = "2";
436 this.p2.ConerRadius = 5;
437 this.p2.Cursor = System.Windows.Forms.Cursors.Hand;
438 this.p2.Dock = System.Windows.Forms.DockStyle.Fill;
439 this.p2.FillColor = System.Drawing.Color.White;
440 this.p2.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
441 this.p2.IsRadius = true;
442 this.p2.IsShowRect = true;
443 this.p2.IsShowTips = false;
444 this.p2.Location = new System.Drawing.Point(122, 5);
445 this.p2.Margin = new System.Windows.Forms.Padding(2, 5, 2, 5);
446 this.p2.Name = "p2";
447 this.p2.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(223)))), ((int)(((byte)(223)))));
448 this.p2.RectWidth = 1;
449 this.p2.Size = new System.Drawing.Size(36, 30);
450 this.p2.TabIndex = 2;
451 this.p2.TabStop = false;
452 this.p2.TipsText = "";
453 this.p2.BtnClick += new System.EventHandler(this.page_BtnClick);
454 //
455 // txtPage
456 //
457 this.txtPage.BackColor = System.Drawing.Color.Transparent;
458 this.txtPage.ConerRadius = 5;
459 this.txtPage.Cursor = System.Windows.Forms.Cursors.IBeam;
460 this.txtPage.DecLength = 2;
461 this.txtPage.FillColor = System.Drawing.Color.Empty;
462 this.txtPage.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
463 this.txtPage.ForeColor = System.Drawing.Color.Gray;
464 this.txtPage.InputText = "";
465 this.txtPage.InputType = HZH_Controls.TextInputType.PositiveInteger;
466 this.txtPage.IsFocusColor = true;
467 this.txtPage.IsRadius = true;
468 this.txtPage.IsShowClearBtn = false;
469 this.txtPage.IsShowKeyboard = false;
470 this.txtPage.IsShowRect = true;
471 this.txtPage.IsShowSearchBtn = false;
472 this.txtPage.KeyBoardType = HZH_Controls.Controls.KeyBoardType.UCKeyBorderAll_EN;
473 this.txtPage.Location = new System.Drawing.Point(524, 5);
474 this.txtPage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
475 this.txtPage.MaxValue = new decimal(new int[] {
476 1000000,
477 0,
478 0,
479 0});
480 this.txtPage.MinValue = new decimal(new int[] {
481 1000000,
482 0,
483 0,
484 -2147483648});
485 this.txtPage.Name = "txtPage";
486 this.txtPage.Padding = new System.Windows.Forms.Padding(5);
487 this.txtPage.PromptColor = System.Drawing.Color.Silver;
488 this.txtPage.PromptFont = new System.Drawing.Font("微软雅黑", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
489 this.txtPage.PromptText = "页码";
490 this.txtPage.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
491 this.txtPage.RectWidth = 1;
492 this.txtPage.RegexPattern = "";
493 this.txtPage.Size = new System.Drawing.Size(62, 30);
494 this.txtPage.TabIndex = 14;
495 //
496 // UCPagerControl2
497 //
498 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
499 this.BackColor = System.Drawing.Color.White;
500 this.Controls.Add(this.tableLayoutPanel1);
501 this.Name = "UCPagerControl2";
502 this.Size = new System.Drawing.Size(921, 41);
503 this.tableLayoutPanel1.ResumeLayout(false);
504 this.ResumeLayout(false);
505
506 }
507
508 #endregion
509
510 private UCBtnExt btnFirst;
511 private UCBtnExt btnPrevious;
512 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
513 private UCBtnExt btnEnd;
514 private UCBtnExt btnNext;
515 private UCBtnExt p8;
516 private UCBtnExt p7;
517 private UCBtnExt p6;
518 private UCBtnExt p5;
519 private UCBtnExt p4;
520 private UCBtnExt p3;
521 private UCBtnExt p2;
522 private UCBtnExt btnToPage;
523 private UCTextBoxEx txtPage;
524 private UCBtnExt p9;
525 private UCBtnExt p1;
526 }
527 }