修改分页工具栏

This commit is contained in:
chfei committed 2026-09-07 14:32:54 +08:00
1 parent d370a58554
commit 8c2cd6b83d
3 files changed
+63 -30

No files matched your search

@@ -55,7 +55,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
num_minprice.Value = 0; num_minprice.Value = 0;
num_maxprice.Value = 999; num_maxprice.Value = 999;
cb_Platform.SelectedIndex = 0; cb_Platform.SelectedIndex = 0;
//ucSplitPage1.TotalPage ucSplitPage1.TotalCount = 0;
} }
@@ -358,6 +358,7 @@ namespace TemuKJD.PDDForms.ProductSelectForms
{ {
ret.List.ForEach(a => dataList.Add(a)); ret.List.ForEach(a => dataList.Add(a));
ucSplitPage1.TotalPage = Math.Max(1, ret.TotalPages); ucSplitPage1.TotalPage = Math.Max(1, ret.TotalPages);
ucSplitPage1.TotalCount = ret.Total;
this.pbLoading.Visible = false; this.pbLoading.Visible = false;
// 异步加载商品缩略图(Column1 绑定 ThumbUrl) // 异步加载商品缩略图(Column1 绑定 ThumbUrl)
ShowDgvImg(); ShowDgvImg();
+8 -8
View File
@@ -52,7 +52,7 @@ namespace TemuKJD.UserControls
this.btnPrev.Cursor = System.Windows.Forms.Cursors.Hand; this.btnPrev.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnPrev.DisabledBackColor = System.Drawing.Color.Empty; this.btnPrev.DisabledBackColor = System.Drawing.Color.Empty;
this.btnPrev.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnPrev.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnPrev.Location = new System.Drawing.Point(259, 0); this.btnPrev.Location = new System.Drawing.Point(235, 0);
this.btnPrev.Margin = new System.Windows.Forms.Padding(0); this.btnPrev.Margin = new System.Windows.Forms.Padding(0);
this.btnPrev.Name = "btnPrev"; this.btnPrev.Name = "btnPrev";
this.btnPrev.Size = new System.Drawing.Size(31, 20); this.btnPrev.Size = new System.Drawing.Size(31, 20);
@@ -102,11 +102,11 @@ namespace TemuKJD.UserControls
// //
this.lblPage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); this.lblPage.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.lblPage.AutoSize = true; this.lblPage.AutoSize = true;
this.lblPage.Location = new System.Drawing.Point(293, 0); this.lblPage.Location = new System.Drawing.Point(269, 0);
this.lblPage.Name = "lblPage"; this.lblPage.Name = "lblPage";
this.lblPage.Size = new System.Drawing.Size(15, 20); this.lblPage.Size = new System.Drawing.Size(39, 20);
this.lblPage.TabIndex = 436; this.lblPage.TabIndex = 436;
this.lblPage.Text = "1"; this.lblPage.Text = "1/1页";
this.lblPage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblPage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// flowLayoutPanel1 // flowLayoutPanel1
@@ -216,19 +216,19 @@ namespace TemuKJD.UserControls
// //
this.lblTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); this.lblTotal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.lblTotal.AutoSize = true; this.lblTotal.AutoSize = true;
this.lblTotal.Location = new System.Drawing.Point(220, 0); this.lblTotal.Location = new System.Drawing.Point(196, 0);
this.lblTotal.Margin = new System.Windows.Forms.Padding(0); this.lblTotal.Margin = new System.Windows.Forms.Padding(0);
this.lblTotal.Name = "lblTotal"; this.lblTotal.Name = "lblTotal";
this.lblTotal.Size = new System.Drawing.Size(39, 20); this.lblTotal.Size = new System.Drawing.Size(39, 20);
this.lblTotal.TabIndex = 446; this.lblTotal.TabIndex = 446;
this.lblTotal.Text = "共1页"; this.lblTotal.Text = "共1条";
this.lblTotal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblTotal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// //
// lblPageSize // lblPageSize
// //
this.lblPageSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom))); this.lblPageSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.lblPageSize.AutoSize = true; this.lblPageSize.AutoSize = true;
this.lblPageSize.Location = new System.Drawing.Point(177, 0); this.lblPageSize.Location = new System.Drawing.Point(153, 0);
this.lblPageSize.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0); this.lblPageSize.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0);
this.lblPageSize.Name = "lblPageSize"; this.lblPageSize.Name = "lblPageSize";
this.lblPageSize.Size = new System.Drawing.Size(37, 20); this.lblPageSize.Size = new System.Drawing.Size(37, 20);
@@ -250,7 +250,7 @@ namespace TemuKJD.UserControls
"1000", "1000",
"2000", "2000",
"5000"}); "5000"});
this.cmbPageSize.Location = new System.Drawing.Point(132, 0); this.cmbPageSize.Location = new System.Drawing.Point(108, 0);
this.cmbPageSize.Margin = new System.Windows.Forms.Padding(0); this.cmbPageSize.Margin = new System.Windows.Forms.Padding(0);
this.cmbPageSize.Name = "cmbPageSize"; this.cmbPageSize.Name = "cmbPageSize";
this.cmbPageSize.RightToLeft = System.Windows.Forms.RightToLeft.No; this.cmbPageSize.RightToLeft = System.Windows.Forms.RightToLeft.No;
+53 -21
View File
@@ -32,6 +32,33 @@ namespace TemuKJD.UserControls
} }
} }
} }
long totalCount = 0;
/// <summary>
/// 总数量
/// </summary>
[Description("总数量"), Category("UserProperty")]
public long TotalCount
{
get { return totalCount; }
set
{
if (totalCount != value && value >= 0)
{
totalCount = value;
// 根据总数量和每页条数计算总页数
int pageSize = this.PageSize;
if (pageSize > 0)
{
this.TotalPage = (int)Math.Ceiling((double)totalCount / pageSize);
}
else
{
this.TotalPage = 1;
}
Refresh();
}
}
}
int totalPage = 1; int totalPage = 1;
public int TotalPage public int TotalPage
@@ -39,18 +66,10 @@ namespace TemuKJD.UserControls
get { return totalPage; } get { return totalPage; }
set set
{ {
if (TotalPage != value && value > 0) if (totalPage != value && value > 0)
{ {
totalPage = value; totalPage = value;
if (InvokeRequired) Refresh();
{
Invoke(new Action(() =>
{
this.lblTotal.Text = "共 " + totalPage + " 页";
}));
}
else
this.lblTotal.Text = "共 " + totalPage + " 页";
} }
} }
} }
@@ -61,18 +80,12 @@ namespace TemuKJD.UserControls
get { return currentPage; } get { return currentPage; }
set set
{ {
if (currentPage != value) // 确保当前页不超过总页数
int newPage = Math.Max(1, Math.Min(totalPage, value));
if (currentPage != newPage)
{ {
currentPage = value; currentPage = newPage;
if (InvokeRequired) Refresh();
{
Invoke(new Action(() =>
{
this.lblPage.Text = "" + currentPage;
}));
}
else
this.lblPage.Text = "" + currentPage;
} }
OnPageChange(this); OnPageChange(this);
} }
@@ -114,6 +127,16 @@ namespace TemuKJD.UserControls
else else
this.cmbPageSize.Text = value.ParseToString(); this.cmbPageSize.Text = value.ParseToString();
} }
// 当每页条数变化时,重新计算总页数
if (totalCount > 0)
{
this.TotalPage = (int)Math.Ceiling((double)totalCount / value);
// 确保当前页不超过新的总页数
if (this.CurrentPage > this.TotalPage)
{
this.CurrentPage = this.TotalPage;
}
}
//OnPageChange(this); //OnPageChange(this);
} }
} }
@@ -147,5 +170,14 @@ namespace TemuKJD.UserControls
int page = this.CurrentPage + 1; int page = this.CurrentPage + 1;
this.CurrentPage = Math.Min(totalPage, page); this.CurrentPage = Math.Min(totalPage, page);
} }
private void Refresh()
{
Invoke(new Action(() =>
{
lblPage.Text = $"{currentPage}/{TotalPage}页";
lblTotal.Text = $"共{TotalCount}条";
}));
}
} }
} }