Commit 083a6d02 HZH

修改表格控件,移除自适应高度和内置翻页控件

1 个父辈 34925690
正在显示 27 个修改的文件 包含 559 行增加357 行删除
...@@ -50,11 +50,12 @@ namespace HZH_Controls.Controls ...@@ -50,11 +50,12 @@ namespace HZH_Controls.Controls
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.ucControlBase1 = new HZH_Controls.Controls.UCControlBase(); this.ucControlBase1 = new HZH_Controls.Controls.UCControlBase();
this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView(); this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView();
this.m_page = new HZH_Controls.Controls.UCPagerControl();
this.panel2 = new System.Windows.Forms.Panel();
this.txtSearch = new HZH_Controls.Controls.UCTextBoxEx(); this.txtSearch = new HZH_Controls.Controls.UCTextBoxEx();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V(); this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V(); this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H(); this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
...@@ -75,23 +76,11 @@ namespace HZH_Controls.Controls ...@@ -75,23 +76,11 @@ namespace HZH_Controls.Controls
this.panel1.Size = new System.Drawing.Size(447, 333); this.panel1.Size = new System.Drawing.Size(447, 333);
this.panel1.TabIndex = 4; this.panel1.TabIndex = 4;
// //
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(5, 47);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(437, 15);
this.panel2.TabIndex = 1;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucControlBase1 // ucControlBase1
// //
this.ucControlBase1.ConerRadius = 5; this.ucControlBase1.ConerRadius = 5;
this.ucControlBase1.Controls.Add(this.ucDataGridView1); this.ucControlBase1.Controls.Add(this.ucDataGridView1);
this.ucControlBase1.Controls.Add(this.m_page);
this.ucControlBase1.Dock = System.Windows.Forms.DockStyle.Fill; this.ucControlBase1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucControlBase1.FillColor = System.Drawing.Color.Transparent; this.ucControlBase1.FillColor = System.Drawing.Color.Transparent;
this.ucControlBase1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.ucControlBase1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
...@@ -109,6 +98,7 @@ namespace HZH_Controls.Controls ...@@ -109,6 +98,7 @@ namespace HZH_Controls.Controls
// //
// ucDataGridView1 // ucDataGridView1
// //
this.ucDataGridView1.AutoScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White; this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null; this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null; this.ucDataGridView1.DataSource = null;
...@@ -117,18 +107,37 @@ namespace HZH_Controls.Controls ...@@ -117,18 +107,37 @@ namespace HZH_Controls.Controls
this.ucDataGridView1.HeadHeight = 40; this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 0; this.ucDataGridView1.HeadPadingLeft = 0;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black; this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false; this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true; this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(5, 5); this.ucDataGridView1.Location = new System.Drawing.Point(5, 5);
this.ucDataGridView1.Name = "ucDataGridView1"; this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 30; this.ucDataGridView1.RowHeight = 30;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(427, 256); this.ucDataGridView1.Size = new System.Drawing.Size(427, 223);
this.ucDataGridView1.TabIndex = 0; this.ucDataGridView1.TabIndex = 0;
this.ucDataGridView1.TabStop = false; this.ucDataGridView1.TabStop = false;
// //
// m_page
//
this.m_page.DataSource = null;
this.m_page.Dock = System.Windows.Forms.DockStyle.Bottom;
this.m_page.Location = new System.Drawing.Point(5, 228);
this.m_page.Name = "m_page";
this.m_page.PageCount = 0;
this.m_page.PageIndex = 1;
this.m_page.PageSize = 10;
this.m_page.Size = new System.Drawing.Size(427, 33);
this.m_page.StartIndex = 0;
this.m_page.TabIndex = 1;
//
// panel2
//
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
this.panel2.Location = new System.Drawing.Point(5, 47);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(437, 15);
this.panel2.TabIndex = 1;
//
// txtSearch // txtSearch
// //
this.txtSearch.BackColor = System.Drawing.Color.Transparent; this.txtSearch.BackColor = System.Drawing.Color.Transparent;
...@@ -137,6 +146,7 @@ namespace HZH_Controls.Controls ...@@ -137,6 +146,7 @@ namespace HZH_Controls.Controls
this.txtSearch.DecLength = 2; this.txtSearch.DecLength = 2;
this.txtSearch.Dock = System.Windows.Forms.DockStyle.Top; this.txtSearch.Dock = System.Windows.Forms.DockStyle.Top;
this.txtSearch.FillColor = System.Drawing.Color.Empty; this.txtSearch.FillColor = System.Drawing.Color.Empty;
this.txtSearch.FocusBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.txtSearch.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.txtSearch.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.txtSearch.InputText = ""; this.txtSearch.InputText = "";
this.txtSearch.InputType = HZH_Controls.TextInputType.NotControl; this.txtSearch.InputType = HZH_Controls.TextInputType.NotControl;
...@@ -170,6 +180,11 @@ namespace HZH_Controls.Controls ...@@ -170,6 +180,11 @@ namespace HZH_Controls.Controls
this.txtSearch.Size = new System.Drawing.Size(437, 42); this.txtSearch.Size = new System.Drawing.Size(437, 42);
this.txtSearch.TabIndex = 0; this.txtSearch.TabIndex = 0;
// //
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucSplitLine_V2 // ucSplitLine_V2
// //
this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232))))); this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
...@@ -270,5 +285,6 @@ namespace HZH_Controls.Controls ...@@ -270,5 +285,6 @@ namespace HZH_Controls.Controls
/// The text search /// The text search
/// </summary> /// </summary>
private UCTextBoxEx txtSearch; private UCTextBoxEx txtSearch;
private UCPagerControl m_page;
} }
} }
...@@ -93,23 +93,20 @@ namespace HZH_Controls.Controls ...@@ -93,23 +93,20 @@ namespace HZH_Controls.Controls
/// The string last search text /// The string last search text
/// </summary> /// </summary>
private string strLastSearchText = string.Empty; private string strLastSearchText = string.Empty;
/// <summary>
/// The m page
/// </summary>
UCPagerControl m_page = new UCPagerControl();
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UCComboxGridPanel" /> class. /// Initializes a new instance of the <see cref="UCComboxGridPanel" /> class.
/// </summary> /// </summary>
public UCComboxGridPanel() public UCComboxGridPanel()
{ {
InitializeComponent(); InitializeComponent();
this.ucDataGridView1.Page = m_page;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.txtSearch.txtInput.TextChanged += txtInput_TextChanged; this.txtSearch.txtInput.TextChanged += txtInput_TextChanged;
this.ucDataGridView1.ItemClick += ucDataGridView1_ItemClick; this.ucDataGridView1.ItemClick += ucDataGridView1_ItemClick;
m_page.ShowSourceChanged += m_page_ShowSourceChanged;
} }
/// <summary> /// <summary>
/// Handles the ItemClick event of the ucDataGridView1 control. /// Handles the ItemClick event of the ucDataGridView1 control.
/// </summary> /// </summary>
...@@ -172,7 +169,7 @@ namespace HZH_Controls.Controls ...@@ -172,7 +169,7 @@ namespace HZH_Controls.Controls
m_page.StartIndex = 0; m_page.StartIndex = 0;
if (!string.IsNullOrEmpty(strText)) if (!string.IsNullOrEmpty(strText))
{ {
strText = strText.ToLower(); strText = strText.ToLower().Trim();
List<object> lst = m_dataSource.FindAll(p => m_columns.Any(c => (c.Format == null ? (p.GetType().GetProperty(c.DataField).GetValue(p, null).ToStringExt()) : c.Format(p.GetType().GetProperty(c.DataField).GetValue(p, null))).ToLower().Contains(strText))); List<object> lst = m_dataSource.FindAll(p => m_columns.Any(c => (c.Format == null ? (p.GetType().GetProperty(c.DataField).GetValue(p, null).ToStringExt()) : c.Format(p.GetType().GetProperty(c.DataField).GetValue(p, null))).ToLower().Contains(strText)));
m_page.DataSource = lst; m_page.DataSource = lst;
} }
...@@ -182,5 +179,10 @@ namespace HZH_Controls.Controls ...@@ -182,5 +179,10 @@ namespace HZH_Controls.Controls
} }
m_page.Reload(); m_page.Reload();
} }
void m_page_ShowSourceChanged(object currentSource)
{
this.ucDataGridView1.DataSource = currentSource;
}
} }
} }
...@@ -53,7 +53,6 @@ namespace HZH_Controls.Controls ...@@ -53,7 +53,6 @@ namespace HZH_Controls.Controls
this.panHeadLeft = new System.Windows.Forms.Panel(); this.panHeadLeft = new System.Windows.Forms.Panel();
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H(); this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panRow = new System.Windows.Forms.Panel(); this.panRow = new System.Windows.Forms.Panel();
this.panPage = new System.Windows.Forms.Panel();
this.panHead.SuspendLayout(); this.panHead.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
...@@ -105,18 +104,8 @@ namespace HZH_Controls.Controls ...@@ -105,18 +104,8 @@ namespace HZH_Controls.Controls
this.panRow.Dock = System.Windows.Forms.DockStyle.Fill; this.panRow.Dock = System.Windows.Forms.DockStyle.Fill;
this.panRow.Location = new System.Drawing.Point(0, 40); this.panRow.Location = new System.Drawing.Point(0, 40);
this.panRow.Name = "panRow"; this.panRow.Name = "panRow";
this.panRow.Size = new System.Drawing.Size(1061, 481); this.panRow.Size = new System.Drawing.Size(1061, 525);
this.panRow.TabIndex = 1; this.panRow.TabIndex = 1;
this.panRow.SizeChanged += new System.EventHandler(this.panRow_SizeChanged);
//
// panPage
//
this.panPage.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panPage.Location = new System.Drawing.Point(0, 521);
this.panPage.Name = "panPage";
this.panPage.Size = new System.Drawing.Size(1061, 44);
this.panPage.TabIndex = 0;
this.panPage.Visible = false;
// //
// UCDataGridView // UCDataGridView
// //
...@@ -124,11 +113,9 @@ namespace HZH_Controls.Controls ...@@ -124,11 +113,9 @@ namespace HZH_Controls.Controls
this.AutoScroll = true; this.AutoScroll = true;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.panRow); this.Controls.Add(this.panRow);
this.Controls.Add(this.panPage);
this.Controls.Add(this.panHead); this.Controls.Add(this.panHead);
this.Name = "UCDataGridView"; this.Name = "UCDataGridView";
this.Size = new System.Drawing.Size(1061, 565); this.Size = new System.Drawing.Size(1061, 565);
this.Resize += new System.EventHandler(this.UCDataGridView_Resize);
this.panHead.ResumeLayout(false); this.panHead.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
...@@ -153,10 +140,6 @@ namespace HZH_Controls.Controls ...@@ -153,10 +140,6 @@ namespace HZH_Controls.Controls
/// </summary> /// </summary>
private System.Windows.Forms.Panel panRow; private System.Windows.Forms.Panel panRow;
/// <summary> /// <summary>
/// The pan page
/// </summary>
private System.Windows.Forms.Panel panPage;
/// <summary>
/// The pan head left /// The pan head left
/// </summary> /// </summary>
private System.Windows.Forms.Panel panHeadLeft; private System.Windows.Forms.Panel panHeadLeft;
......
...@@ -101,7 +101,6 @@ namespace HZH_Controls.Controls ...@@ -101,7 +101,6 @@ namespace HZH_Controls.Controls
// //
this.ucDGVChild.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.ucDGVChild.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.ucDGVChild.AutoRowsScroll = false;
this.ucDGVChild.BackColor = System.Drawing.Color.White; this.ucDGVChild.BackColor = System.Drawing.Color.White;
this.ucDGVChild.Columns = null; this.ucDGVChild.Columns = null;
this.ucDGVChild.DataSource = null; this.ucDGVChild.DataSource = null;
...@@ -109,12 +108,10 @@ namespace HZH_Controls.Controls ...@@ -109,12 +108,10 @@ namespace HZH_Controls.Controls
this.ucDGVChild.HeadHeight = 40; this.ucDGVChild.HeadHeight = 40;
this.ucDGVChild.HeadPadingLeft = 0; this.ucDGVChild.HeadPadingLeft = 0;
this.ucDGVChild.HeadTextColor = System.Drawing.Color.Black; this.ucDGVChild.HeadTextColor = System.Drawing.Color.Black;
this.ucDGVChild.IsCloseAutoHeight = false;
this.ucDGVChild.IsShowCheckBox = false; this.ucDGVChild.IsShowCheckBox = false;
this.ucDGVChild.IsShowHead = false; this.ucDGVChild.IsShowHead = false;
this.ucDGVChild.Location = new System.Drawing.Point(25, 0); this.ucDGVChild.Location = new System.Drawing.Point(25, 0);
this.ucDGVChild.Name = "ucDGVChild"; this.ucDGVChild.Name = "ucDGVChild";
this.ucDGVChild.Page = null;
this.ucDGVChild.RowHeight = 40; this.ucDGVChild.RowHeight = 40;
this.ucDGVChild.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.ucDGVChild.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDGVChild.Size = new System.Drawing.Size(636, 100); this.ucDGVChild.Size = new System.Drawing.Size(636, 100);
......
...@@ -137,7 +137,6 @@ namespace HZH_Controls.Controls ...@@ -137,7 +137,6 @@ namespace HZH_Controls.Controls
{ {
InitializeComponent(); InitializeComponent();
this.ucDGVChild.RowType = this.GetType(); this.ucDGVChild.RowType = this.GetType();
this.ucDGVChild.IsCloseAutoHeight = true;
this.SizeChanged += UCDataGridViewTreeRow_SizeChanged; this.SizeChanged += UCDataGridViewTreeRow_SizeChanged;
this.ucDGVChild.ItemClick += (a, b) => this.ucDGVChild.ItemClick += (a, b) =>
{ {
...@@ -160,11 +159,14 @@ namespace HZH_Controls.Controls ...@@ -160,11 +159,14 @@ namespace HZH_Controls.Controls
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
void UCDataGridViewTreeRow_SizeChanged(object sender, EventArgs e) void UCDataGridViewTreeRow_SizeChanged(object sender, EventArgs e)
{ {
if (this.Parent.Parent.Parent != null && this.Parent.Parent.Parent.Name == "panChildGrid" && this.panLeft.Tag.ToInt() == 1) if (this.Parent != null)
{ {
int intHeight = this.Parent.Parent.Controls[0].Controls.ToArray().Sum(p => p.Height); if (this.Parent.Parent.Parent != null && this.Parent.Parent.Parent.Name == "panChildGrid" && this.panLeft.Tag.ToInt() == 1)
if (this.Parent.Parent.Parent.Height != intHeight) {
this.Parent.Parent.Parent.Height = intHeight; int intHeight = this.Parent.Parent.Controls[0].Controls.ToArray().Sum(p => p.Height);
if (this.Parent.Parent.Parent.Height != intHeight)
this.Parent.Parent.Parent.Height = intHeight;
}
} }
} }
...@@ -307,14 +309,17 @@ namespace HZH_Controls.Controls ...@@ -307,14 +309,17 @@ namespace HZH_Controls.Controls
box.CheckedChangeEvent += (a, b) => box.CheckedChangeEvent += (a, b) =>
{ {
IsChecked = box.Checked; IsChecked = box.Checked;
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked); if (this.ucDGVChild.Rows != null)
if (CheckBoxChangeEvent != null)
{ {
CheckBoxChangeEvent(a, new DataGridViewEventArgs() this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked);
if (CheckBoxChangeEvent != null)
{ {
CellControl = box, CheckBoxChangeEvent(a, new DataGridViewEventArgs()
CellIndex = 0 {
}); CellControl = box,
CellIndex = 0
});
}
} }
}; };
c = box; c = box;
......
// *********************************************************************** // ***********************************************************************
// Assembly : HZH_Controls // Assembly : HZH_Controls
// Created : 08-09-2019 // Created : 08-09-2019
// //
// *********************************************************************** // ***********************************************************************
// <copyright file="IPageControl.cs"> // <copyright file="IPageControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright> // </copyright>
// //
// Blog: https://www.cnblogs.com/bfyx // Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl // GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
// //
// If you use this code, please keep this note. // If you use this code, please keep this note.
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
/// <summary> /// <summary>
/// Interface IPageControl /// Interface IPageControl
/// </summary> /// </summary>
public interface IPageControl public interface IPageControl
{ {
/// <summary> /// <summary>
/// 数据源改变时发生 /// 数据源改变时发生
/// </summary> /// </summary>
event PageControlEventHandler ShowSourceChanged; event PageControlEventHandler ShowSourceChanged;
/// <summary> /// <summary>
/// 数据源 /// 数据源
/// </summary> /// </summary>
/// <value>The data source.</value> /// <value>The data source.</value>
List<object> DataSource { get; set; } List<object> DataSource { get; set; }
/// <summary> /// <summary>
/// 显示数量 /// 显示数量
/// </summary> /// </summary>
/// <value>The size of the page.</value> /// <value>The size of the page.</value>
int PageSize { get; set; } int PageSize { get; set; }
/// <summary> /// <summary>
/// 开始下标 /// 开始下标
/// </summary> /// </summary>
/// <value>The start index.</value> /// <value>The start index.</value>
int StartIndex { get; set; } int StartIndex { get; set; }
/// <summary> /// <summary>
/// 第一页 /// 第一页
/// </summary> /// </summary>
void FirstPage(); void FirstPage();
/// <summary> /// <summary>
/// 前一页 /// 前一页
/// </summary> /// </summary>
void PreviousPage(); void PreviousPage();
/// <summary> /// <summary>
/// 下一页 /// 下一页
/// </summary> /// </summary>
void NextPage(); void NextPage();
/// <summary> /// <summary>
/// 最后一页 /// 最后一页
/// </summary> /// </summary>
void EndPage(); void EndPage();
/// <summary> /// <summary>
/// 重新加载 /// 重新加载
/// </summary> /// </summary>
void Reload(); void Reload();
/// <summary> /// <summary>
/// 获取当前页数据 /// 获取当前页数据
/// </summary> /// </summary>
/// <returns>List&lt;System.Object&gt;.</returns> /// <returns>List&lt;System.Object&gt;.</returns>
List<object> GetCurrentSource(); List<object> GetCurrentSource();
/// <summary> /// <summary>
/// 总页数 /// 总页数
/// </summary> /// </summary>
/// <value>The page count.</value> /// <value>The page count.</value>
int PageCount { get; set; } int PageCount { get; set; }
/// <summary> /// <summary>
/// 当前页 /// 当前页
/// </summary> /// </summary>
/// <value>The index of the page.</value> /// <value>The index of the page.</value>
int PageIndex { get; set; } int PageIndex { get; set; }
} PageModel PageModel { get; set; }
} }
}
// *********************************************************************** // ***********************************************************************
// Assembly : HZH_Controls // Assembly : HZH_Controls
// Created : 08-09-2019 // Created : 08-09-2019
// //
// *********************************************************************** // ***********************************************************************
// <copyright file="PageControlEventHandler.cs"> // <copyright file="PageControlEventHandler.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright> // </copyright>
// //
// Blog: https://www.cnblogs.com/bfyx // Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl // GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
// //
// If you use this code, please keep this note. // If you use this code, please keep this note.
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
/// <summary> /// <summary>
/// Delegate PageControlEventHandler /// Delegate PageControlEventHandler
/// </summary> /// </summary>
/// <param name="currentSource">The current source.</param> /// <param name="currentSource">The current source.</param>
[Serializable] [Serializable]
[ComVisible(true)] [ComVisible(true)]
public delegate void PageControlEventHandler(object currentSource); public delegate void PageControlEventHandler(object currentSource);
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// 翻页控件类型
/// </summary>
public enum PageModel
{
/// <summary>
/// 数据模式
/// </summary>
Soure,
/// <summary>
/// 总页数模式
/// </summary>
PageCount
}
}
// *********************************************************************** // ***********************************************************************
// Assembly : HZH_Controls // Assembly : HZH_Controls
// Created : 08-09-2019 // Created : 08-09-2019
// //
// *********************************************************************** // ***********************************************************************
// <copyright file="UCPagerControl.cs"> // <copyright file="UCPagerControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright> // </copyright>
// //
// Blog: https://www.cnblogs.com/bfyx // Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl // GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
// //
// If you use this code, please keep this note. // If you use this code, please keep this note.
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
/// <summary> /// <summary>
/// Class UCPagerControl. /// Class UCPagerControl.
/// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" /> /// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
/// </summary> /// </summary>
/// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" /> /// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
[ToolboxItem(true)] [ToolboxItem(true)]
public partial class UCPagerControl : UCPagerControlBase public partial class UCPagerControl : UCPagerControlBase
{ {
/// <summary> public override int PageCount
/// Initializes a new instance of the <see cref="UCPagerControl" /> class. {
/// </summary> get
public UCPagerControl() {
{ return base.PageCount;
InitializeComponent(); }
} set
{
/// <summary> base.PageCount = value;
/// Handles the MouseDown event of the panel1 control. if (PageCount <= 1)
/// </summary> {
/// <param name="sender">The source of the event.</param> ShowBtn(false, false);
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> }
private void panel1_MouseDown(object sender, MouseEventArgs e) else
{ {
PreviousPage(); ShowBtn(false, PageCount > 1);
} }
}
/// <summary> }
/// Handles the MouseDown event of the panel2 control.
/// </summary> public override int PageIndex
/// <param name="sender">The source of the event.</param> {
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> get
private void panel2_MouseDown(object sender, MouseEventArgs e) {
{ return base.PageIndex;
NextPage(); }
} set
{
/// <summary> base.PageIndex = value;
/// Handles the MouseDown event of the panel3 control. if (PageCount <= 1)
/// </summary> {
/// <param name="sender">The source of the event.</param> ShowBtn(false, false);
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> }
private void panel3_MouseDown(object sender, MouseEventArgs e) else
{ {
FirstPage(); ShowBtn(false, PageCount > 1);
} }
}
/// <summary> }
/// Handles the MouseDown event of the panel4 control. /// <summary>
/// </summary> /// Initializes a new instance of the <see cref="UCPagerControl" /> class.
/// <param name="sender">The source of the event.</param> /// </summary>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> public UCPagerControl()
private void panel4_MouseDown(object sender, MouseEventArgs e) {
{ InitializeComponent();
EndPage(); }
}
/// <summary>
/// <summary> /// Handles the MouseDown event of the panel1 control.
/// Shows the BTN. /// </summary>
/// </summary> /// <param name="sender">The source of the event.</param>
/// <param name="blnLeftBtn">if set to <c>true</c> [BLN left BTN].</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
/// <param name="blnRightBtn">if set to <c>true</c> [BLN right BTN].</param> private void panel1_MouseDown(object sender, MouseEventArgs e)
protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn) {
{ PreviousPage();
panel1.Visible = panel3.Visible = blnLeftBtn; }
panel2.Visible = panel4.Visible = blnRightBtn;
} /// <summary>
} /// Handles the MouseDown event of the panel2 control.
} /// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
private void panel2_MouseDown(object sender, MouseEventArgs e)
{
NextPage();
}
/// <summary>
/// Handles the MouseDown event of the panel3 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
private void panel3_MouseDown(object sender, MouseEventArgs e)
{
FirstPage();
}
/// <summary>
/// Handles the MouseDown event of the panel4 control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
private void panel4_MouseDown(object sender, MouseEventArgs e)
{
EndPage();
}
/// <summary>
/// Shows the BTN.
/// </summary>
/// <param name="blnLeftBtn">if set to <c>true</c> [BLN left BTN].</param>
/// <param name="blnRightBtn">if set to <c>true</c> [BLN right BTN].</param>
protected override void ShowBtn(bool blnLeftBtn, bool blnRightBtn)
{
panel1.Visible = panel3.Visible = blnLeftBtn;
panel2.Visible = panel4.Visible = blnRightBtn;
}
}
}
...@@ -105,12 +105,48 @@ namespace HZH_Controls.Controls ...@@ -105,12 +105,48 @@ namespace HZH_Controls.Controls
set set
{ {
base.PageSize = value; base.PageSize = value;
ResetPageCount(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ResetPageCount();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
}
public override int PageCount
{
get
{
return base.PageCount;
}
set
{
base.PageCount = value;
ReloadPage();
}
}
public override int PageIndex
{
get
{
return base.PageIndex;
}
set
{
base.PageIndex = value;
ReloadPage();
} }
} }
...@@ -122,12 +158,22 @@ namespace HZH_Controls.Controls ...@@ -122,12 +158,22 @@ namespace HZH_Controls.Controls
if (PageIndex == 1) if (PageIndex == 1)
return; return;
PageIndex = 1; PageIndex = 1;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
...@@ -141,13 +187,22 @@ namespace HZH_Controls.Controls ...@@ -141,13 +187,22 @@ namespace HZH_Controls.Controls
return; return;
} }
PageIndex--; PageIndex--;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null) {
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{ {
ShowSourceChanged(s); if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
...@@ -161,12 +216,22 @@ namespace HZH_Controls.Controls ...@@ -161,12 +216,22 @@ namespace HZH_Controls.Controls
return; return;
} }
PageIndex++; PageIndex++;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
...@@ -178,12 +243,22 @@ namespace HZH_Controls.Controls ...@@ -178,12 +243,22 @@ namespace HZH_Controls.Controls
if (PageIndex == PageCount) if (PageIndex == PageCount)
return; return;
PageIndex = PageCount; PageIndex = PageCount;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null) {
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{ {
ShowSourceChanged(s); if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
...@@ -318,11 +393,21 @@ namespace HZH_Controls.Controls ...@@ -318,11 +393,21 @@ namespace HZH_Controls.Controls
PageIndex = (sender as UCBtnExt).BtnText.ToInt(); PageIndex = (sender as UCBtnExt).BtnText.ToInt();
StartIndex = (PageIndex - 1) * PageSize; StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{ {
ShowSourceChanged(s); if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
...@@ -389,10 +474,20 @@ namespace HZH_Controls.Controls ...@@ -389,10 +474,20 @@ namespace HZH_Controls.Controls
PageIndex = txtPage.InputText.ToInt(); PageIndex = txtPage.InputText.ToInt();
StartIndex = (PageIndex - 1) * PageSize; StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
var s = GetCurrentSource(); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
} }
} }
} }
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
// //
// dgvRight // dgvRight
// //
this.dgvRight.AutoRowsScroll = true;
this.dgvRight.BackColor = System.Drawing.Color.White; this.dgvRight.BackColor = System.Drawing.Color.White;
this.dgvRight.Columns = null; this.dgvRight.Columns = null;
this.dgvRight.DataSource = null; this.dgvRight.DataSource = null;
...@@ -100,12 +100,11 @@ ...@@ -100,12 +100,11 @@
this.dgvRight.HeadHeight = 40; this.dgvRight.HeadHeight = 40;
this.dgvRight.HeadPadingLeft = 0; this.dgvRight.HeadPadingLeft = 0;
this.dgvRight.HeadTextColor = System.Drawing.Color.Black; this.dgvRight.HeadTextColor = System.Drawing.Color.Black;
this.dgvRight.IsCloseAutoHeight = false;
this.dgvRight.IsShowCheckBox = true; this.dgvRight.IsShowCheckBox = true;
this.dgvRight.IsShowHead = true; this.dgvRight.IsShowHead = true;
this.dgvRight.Location = new System.Drawing.Point(1, 1); this.dgvRight.Location = new System.Drawing.Point(1, 1);
this.dgvRight.Name = "dgvRight"; this.dgvRight.Name = "dgvRight";
this.dgvRight.Page = null;
this.dgvRight.RowHeight = 40; this.dgvRight.RowHeight = 40;
this.dgvRight.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.dgvRight.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.dgvRight.Size = new System.Drawing.Size(194, 395); this.dgvRight.Size = new System.Drawing.Size(194, 395);
...@@ -196,7 +195,6 @@ ...@@ -196,7 +195,6 @@
// //
// dgvLeft // dgvLeft
// //
this.dgvLeft.AutoRowsScroll = true;
this.dgvLeft.BackColor = System.Drawing.Color.White; this.dgvLeft.BackColor = System.Drawing.Color.White;
this.dgvLeft.Columns = null; this.dgvLeft.Columns = null;
this.dgvLeft.DataSource = null; this.dgvLeft.DataSource = null;
...@@ -205,12 +203,10 @@ ...@@ -205,12 +203,10 @@
this.dgvLeft.HeadHeight = 40; this.dgvLeft.HeadHeight = 40;
this.dgvLeft.HeadPadingLeft = 0; this.dgvLeft.HeadPadingLeft = 0;
this.dgvLeft.HeadTextColor = System.Drawing.Color.Black; this.dgvLeft.HeadTextColor = System.Drawing.Color.Black;
this.dgvLeft.IsCloseAutoHeight = false;
this.dgvLeft.IsShowCheckBox = true; this.dgvLeft.IsShowCheckBox = true;
this.dgvLeft.IsShowHead = true; this.dgvLeft.IsShowHead = true;
this.dgvLeft.Location = new System.Drawing.Point(1, 1); this.dgvLeft.Location = new System.Drawing.Point(1, 1);
this.dgvLeft.Name = "dgvLeft"; this.dgvLeft.Name = "dgvLeft";
this.dgvLeft.Page = null;
this.dgvLeft.RowHeight = 40; this.dgvLeft.RowHeight = 40;
this.dgvLeft.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.dgvLeft.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.dgvLeft.Size = new System.Drawing.Size(193, 395); this.dgvLeft.Size = new System.Drawing.Size(193, 395);
......
...@@ -122,8 +122,6 @@ namespace HZH_Controls.Controls ...@@ -122,8 +122,6 @@ namespace HZH_Controls.Controls
public UCTransfer() public UCTransfer()
{ {
InitializeComponent(); InitializeComponent();
dgvLeft.IsCloseAutoHeight = true;
dgvRight.IsCloseAutoHeight = true;
LeftColumns = new DataGridViewColumnEntity[0]; LeftColumns = new DataGridViewColumnEntity[0];
RightColumns = new DataGridViewColumnEntity[0]; RightColumns = new DataGridViewColumnEntity[0];
LeftDataSource = new object[0]; LeftDataSource = new object[0];
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
</Compile> </Compile>
<Compile Include="Controls\Navigation\CrumbNavigationClickEventArgs.cs" /> <Compile Include="Controls\Navigation\CrumbNavigationClickEventArgs.cs" />
<Compile Include="Controls\Navigation\CrumbNavigationItem.cs" /> <Compile Include="Controls\Navigation\CrumbNavigationItem.cs" />
<Compile Include="Controls\Page\PageModel.cs" />
<Compile Include="Controls\Panel\UCPanelQuote.cs"> <Compile Include="Controls\Panel\UCPanelQuote.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
...@@ -258,8 +259,8 @@ ...@@ -258,8 +259,8 @@
<DependentUpon>UCLEDTime.cs</DependentUpon> <DependentUpon>UCLEDTime.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\List\IListViewItem.cs" /> <Compile Include="Controls\List\IListViewItem.cs" />
<Compile Include="Controls\List\IPageControl.cs" /> <Compile Include="Controls\Page\IPageControl.cs" />
<Compile Include="Controls\List\PageControlEventHandler.cs" /> <Compile Include="Controls\Page\PageControlEventHandler.cs" />
<Compile Include="Controls\List\UCListView.cs"> <Compile Include="Controls\List\UCListView.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -272,16 +273,16 @@ ...@@ -272,16 +273,16 @@
<Compile Include="Controls\List\UCListViewItem.Designer.cs"> <Compile Include="Controls\List\UCListViewItem.Designer.cs">
<DependentUpon>UCListViewItem.cs</DependentUpon> <DependentUpon>UCListViewItem.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\List\UCPagerControl.cs"> <Compile Include="Controls\Page\UCPagerControl.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\List\UCPagerControl.Designer.cs"> <Compile Include="Controls\Page\UCPagerControl.Designer.cs">
<DependentUpon>UCPagerControl.cs</DependentUpon> <DependentUpon>UCPagerControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\List\UCPagerControl2.cs"> <Compile Include="Controls\Page\UCPagerControl2.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\List\UCPagerControl2.Designer.cs"> <Compile Include="Controls\Page\UCPagerControl2.Designer.cs">
<DependentUpon>UCPagerControl2.cs</DependentUpon> <DependentUpon>UCPagerControl2.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Menu\IMenuItem.cs" /> <Compile Include="Controls\Menu\IMenuItem.cs" />
...@@ -482,7 +483,7 @@ ...@@ -482,7 +483,7 @@
<Compile Include="Controls\List\UCListItemExt.Designer.cs"> <Compile Include="Controls\List\UCListItemExt.Designer.cs">
<DependentUpon>UCListItemExt.cs</DependentUpon> <DependentUpon>UCListItemExt.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\List\UCPagerControlBase.cs"> <Compile Include="Controls\Page\UCPagerControlBase.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Controls\Process\UCProcessExt.cs"> <Compile Include="Controls\Process\UCProcessExt.cs">
...@@ -705,13 +706,13 @@ ...@@ -705,13 +706,13 @@
<EmbeddedResource Include="Controls\List\UCListViewItem.resx"> <EmbeddedResource Include="Controls\List\UCListViewItem.resx">
<DependentUpon>UCListViewItem.cs</DependentUpon> <DependentUpon>UCListViewItem.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControl.resx"> <EmbeddedResource Include="Controls\Page\UCPagerControl.resx">
<DependentUpon>UCPagerControl.cs</DependentUpon> <DependentUpon>UCPagerControl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControl2.resx"> <EmbeddedResource Include="Controls\Page\UCPagerControl2.resx">
<DependentUpon>UCPagerControl2.cs</DependentUpon> <DependentUpon>UCPagerControl2.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControlBase.resx"> <EmbeddedResource Include="Controls\Page\UCPagerControlBase.resx">
<DependentUpon>UCPagerControlBase.cs</DependentUpon> <DependentUpon>UCPagerControlBase.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Controls\Menu\UCMenu.resx"> <EmbeddedResource Include="Controls\Menu\UCMenu.resx">
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
// ucDataGridView1 // ucDataGridView1
// //
this.ucDataGridView1.AutoRowsScroll = false;
this.ucDataGridView1.BackColor = System.Drawing.Color.White; this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null; this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null; this.ucDataGridView1.DataSource = null;
...@@ -42,12 +41,10 @@ ...@@ -42,12 +41,10 @@
this.ucDataGridView1.HeadHeight = 40; this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 0; this.ucDataGridView1.HeadPadingLeft = 0;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black; this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false; this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true; this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0); this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1"; this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 41; this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(739, 599); this.ucDataGridView1.Size = new System.Drawing.Size(739, 599);
......
...@@ -16,18 +16,8 @@ namespace Test.UC ...@@ -16,18 +16,8 @@ namespace Test.UC
public UCTestGridTable() public UCTestGridTable()
{ {
InitializeComponent(); InitializeComponent();
ucDataGridView1.SizeChanged += ucDataGridView1_SizeChanged;
ucDataGridView1.IsCloseAutoHeight = false;
} }
void ucDataGridView1_SizeChanged(object sender, EventArgs e)
{
if (this.ucDataGridView1.Page != null)
{
this.ucDataGridView1.Page.PageSize = this.ucDataGridView1.ShowCount;
this.ucDataGridView1.DataSource= this.ucDataGridView1.Page.GetCurrentSource();
}
}
private void UCTestGridTable_Load(object sender, EventArgs e) private void UCTestGridTable_Load(object sender, EventArgs e)
{ {
...@@ -51,12 +41,8 @@ namespace Test.UC ...@@ -51,12 +41,8 @@ namespace Test.UC
Sex = i % 2 Sex = i % 2
}; };
lstSource.Add(model); lstSource.Add(model);
} }
this.ucDataGridView1.DataSource = lstSource;
var page = new UCPagerControl2();
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
} }
} }
......
...@@ -32,16 +32,23 @@ ...@@ -32,16 +32,23 @@
this.ucPagerControl21 = new HZH_Controls.Controls.UCPagerControl2(); this.ucPagerControl21 = new HZH_Controls.Controls.UCPagerControl2();
this.ucPagerControl1 = new HZH_Controls.Controls.UCPagerControl(); this.ucPagerControl1 = new HZH_Controls.Controls.UCPagerControl();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.ucPagerControl22 = new HZH_Controls.Controls.UCPagerControl2();
this.ucPagerControl2 = new HZH_Controls.Controls.UCPagerControl();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// ucPagerControl21 // ucPagerControl21
// //
this.ucPagerControl21.BackColor = System.Drawing.Color.White; this.ucPagerControl21.BackColor = System.Drawing.Color.White;
this.ucPagerControl21.DataSource = ((System.Collections.Generic.List<object>)(resources.GetObject("ucPagerControl21.DataSource"))); this.ucPagerControl21.DataSource = ((System.Collections.Generic.List<object>)(resources.GetObject("ucPagerControl21.DataSource")));
this.ucPagerControl21.Location = new System.Drawing.Point(31, 19); this.ucPagerControl21.Location = new System.Drawing.Point(21, 35);
this.ucPagerControl21.Name = "ucPagerControl21"; this.ucPagerControl21.Name = "ucPagerControl21";
this.ucPagerControl21.PageCount = 0; this.ucPagerControl21.PageCount = 0;
this.ucPagerControl21.PageIndex = 1; this.ucPagerControl21.PageIndex = 1;
this.ucPagerControl21.PageModel = HZH_Controls.Controls.PageModel.Soure;
this.ucPagerControl21.PageSize = 0; this.ucPagerControl21.PageSize = 0;
this.ucPagerControl21.Size = new System.Drawing.Size(709, 41); this.ucPagerControl21.Size = new System.Drawing.Size(709, 41);
this.ucPagerControl21.StartIndex = 0; this.ucPagerControl21.StartIndex = 0;
...@@ -50,10 +57,11 @@ ...@@ -50,10 +57,11 @@
// ucPagerControl1 // ucPagerControl1
// //
this.ucPagerControl1.DataSource = null; this.ucPagerControl1.DataSource = null;
this.ucPagerControl1.Location = new System.Drawing.Point(60, 77); this.ucPagerControl1.Location = new System.Drawing.Point(21, 82);
this.ucPagerControl1.Name = "ucPagerControl1"; this.ucPagerControl1.Name = "ucPagerControl1";
this.ucPagerControl1.PageCount = 0; this.ucPagerControl1.PageCount = 0;
this.ucPagerControl1.PageIndex = 1; this.ucPagerControl1.PageIndex = 1;
this.ucPagerControl1.PageModel = HZH_Controls.Controls.PageModel.Soure;
this.ucPagerControl1.PageSize = 1; this.ucPagerControl1.PageSize = 1;
this.ucPagerControl1.Size = new System.Drawing.Size(304, 58); this.ucPagerControl1.Size = new System.Drawing.Size(304, 58);
this.ucPagerControl1.StartIndex = 0; this.ucPagerControl1.StartIndex = 0;
...@@ -62,24 +70,75 @@ ...@@ -62,24 +70,75 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(58, 182); this.label1.Location = new System.Drawing.Point(477, 128);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(197, 12); this.label1.Size = new System.Drawing.Size(197, 12);
this.label1.TabIndex = 7; this.label1.TabIndex = 7;
this.label1.Text = "模拟1000条数据,每页10条展示分页"; this.label1.Text = "模拟1000条数据,每页10条展示分页";
// //
// groupBox1
//
this.groupBox1.Controls.Add(this.ucPagerControl21);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.ucPagerControl1);
this.groupBox1.Location = new System.Drawing.Point(15, 13);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(753, 176);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "数据模式(PageModel=Source)";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.ucPagerControl22);
this.groupBox2.Controls.Add(this.ucPagerControl2);
this.groupBox2.Location = new System.Drawing.Point(15, 216);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(753, 176);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "页数模式(PageModel=PageCount)";
//
// ucPagerControl22
//
this.ucPagerControl22.BackColor = System.Drawing.Color.White;
this.ucPagerControl22.DataSource = ((System.Collections.Generic.List<object>)(resources.GetObject("ucPagerControl22.DataSource")));
this.ucPagerControl22.Location = new System.Drawing.Point(21, 35);
this.ucPagerControl22.Name = "ucPagerControl22";
this.ucPagerControl22.PageCount = 0;
this.ucPagerControl22.PageIndex = 1;
this.ucPagerControl22.PageModel = HZH_Controls.Controls.PageModel.PageCount;
this.ucPagerControl22.PageSize = 0;
this.ucPagerControl22.Size = new System.Drawing.Size(709, 41);
this.ucPagerControl22.StartIndex = 0;
this.ucPagerControl22.TabIndex = 5;
//
// ucPagerControl2
//
this.ucPagerControl2.DataSource = null;
this.ucPagerControl2.Location = new System.Drawing.Point(21, 82);
this.ucPagerControl2.Name = "ucPagerControl2";
this.ucPagerControl2.PageCount = 0;
this.ucPagerControl2.PageIndex = 1;
this.ucPagerControl2.PageModel = HZH_Controls.Controls.PageModel.PageCount;
this.ucPagerControl2.PageSize = 1;
this.ucPagerControl2.Size = new System.Drawing.Size(304, 58);
this.ucPagerControl2.StartIndex = 0;
this.ucPagerControl2.TabIndex = 6;
//
// UCTestPage // UCTestPage
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.label1); this.Controls.Add(this.groupBox2);
this.Controls.Add(this.ucPagerControl1); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.ucPagerControl21);
this.Name = "UCTestPage"; this.Name = "UCTestPage";
this.Size = new System.Drawing.Size(782, 304); this.Size = new System.Drawing.Size(782, 567);
this.Load += new System.EventHandler(this.UCTestPage_Load); this.Load += new System.EventHandler(this.UCTestPage_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
...@@ -88,5 +147,9 @@ ...@@ -88,5 +147,9 @@
private HZH_Controls.Controls.UCPagerControl2 ucPagerControl21; private HZH_Controls.Controls.UCPagerControl2 ucPagerControl21;
private HZH_Controls.Controls.UCPagerControl ucPagerControl1; private HZH_Controls.Controls.UCPagerControl ucPagerControl1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private HZH_Controls.Controls.UCPagerControl2 ucPagerControl22;
private HZH_Controls.Controls.UCPagerControl ucPagerControl2;
} }
} }
...@@ -32,6 +32,12 @@ namespace Test.UC ...@@ -32,6 +32,12 @@ namespace Test.UC
ucPagerControl1.DataSource = lstPage2; ucPagerControl1.DataSource = lstPage2;
this.ucPagerControl1.FirstPage(); this.ucPagerControl1.FirstPage();
ucPagerControl22.PageCount = 10;
ucPagerControl22.PageIndex = 1;
ucPagerControl2.PageCount = 10;
ucPagerControl2.PageIndex = 1;
} }
} }
} }
...@@ -126,4 +126,13 @@ ...@@ -126,4 +126,13 @@
ZW1zBV9zaXplCF92ZXJzaW9uBQAACAgCAAAACQMAAAAAAAAAAAAAABADAAAAAAAAAAs= ZW1zBV9zaXplCF92ZXJzaW9uBQAACAgCAAAACQMAAAAAAAAAAAAAABADAAAAAAAAAAs=
</value> </value>
</data> </data>
<data name="ucPagerControl22.DataSource" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLk9iamVjdAMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBQAACAgCAAAACQMAAAAAAAAAAAAAABADAAAAAAAAAAs=
</value>
</data>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
// //
// ucDataGridView1 // ucDataGridView1
// //
this.ucDataGridView1.AutoRowsScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White; this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null; this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null; this.ucDataGridView1.DataSource = null;
...@@ -42,12 +41,10 @@ ...@@ -42,12 +41,10 @@
this.ucDataGridView1.HeadHeight = 40; this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 24; this.ucDataGridView1.HeadPadingLeft = 24;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black; this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false; this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true; this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0); this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1"; this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 41; this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow); this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(825, 674); this.ucDataGridView1.Size = new System.Drawing.Size(825, 674);
......
...@@ -15,19 +15,9 @@ namespace Test.UC ...@@ -15,19 +15,9 @@ namespace Test.UC
{ {
public UCTestTreeGridTable() public UCTestTreeGridTable()
{ {
InitializeComponent(); InitializeComponent();
ucDataGridView1.SizeChanged += ucDataGridView1_SizeChanged;
} }
void ucDataGridView1_SizeChanged(object sender, EventArgs e)
{
if (this.ucDataGridView1.Page != null)
{
this.ucDataGridView1.ResetShowCount();
this.ucDataGridView1.Page.PageSize = this.ucDataGridView1.ShowCount;
this.ucDataGridView1.DataSource = this.ucDataGridView1.Page.GetCurrentSource();
}
}
private void UCTestTreeGridTable_Load(object sender, EventArgs e) private void UCTestTreeGridTable_Load(object sender, EventArgs e)
{ {
...@@ -55,10 +45,7 @@ namespace Test.UC ...@@ -55,10 +45,7 @@ namespace Test.UC
AddChilds(model, 5); AddChilds(model, 5);
} }
var page = new UCPagerControl2(); this.ucDataGridView1.DataSource = lstSource;
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
} }
private void AddChilds(TestGridModel tm, int intCount) private void AddChilds(TestGridModel tm, int intCount)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!