Commit 083a6d02 HZH

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

1 个父辈 34925690
正在显示 27 个修改的文件 包含 1268 行增加1131 行删除
...@@ -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;
......
...@@ -98,11 +98,6 @@ namespace HZH_Controls.Controls ...@@ -98,11 +98,6 @@ namespace HZH_Controls.Controls
{ {
m_isShowHead = value; m_isShowHead = value;
panHead.Visible = value; panHead.Visible = value;
if (m_page != null)
{
ResetShowCount();
m_page.PageSize = m_showCount;
}
} }
} }
/// <summary> /// <summary>
...@@ -161,25 +156,17 @@ namespace HZH_Controls.Controls ...@@ -161,25 +156,17 @@ namespace HZH_Controls.Controls
set { m_rowHeight = value; } set { m_rowHeight = value; }
} }
/// <summary>
/// The m show count
/// </summary>
private int m_showCount = 0;
/// <summary> /// <summary>
/// Gets the show count. /// Gets the show count.
/// </summary> /// </summary>
/// <value>The show count.</value> /// <value>The show count.</value>
[Description("可显示个数"), Category("自定义")] [Description("当前高度可显示行个数"), Category("自定义")]
public int ShowCount public int ShowCount
{ {
get { return m_showCount; } get
private set
{ {
m_showCount = value; return this.panRow.Height / (m_rowHeight);
if (m_page != null)
{
m_page.PageSize = value;
}
} }
} }
...@@ -263,32 +250,12 @@ namespace HZH_Controls.Controls ...@@ -263,32 +250,12 @@ namespace HZH_Controls.Controls
return; return;
if (!typeof(IDataGridViewRow).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(Control))) if (!typeof(IDataGridViewRow).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(Control)))
throw new Exception("行控件没有实现IDataGridViewRow接口"); throw new Exception("行控件没有实现IDataGridViewRow接口");
m_rowType = value; m_rowType = value;
if (value == typeof(UCDataGridViewTreeRow))
IsCloseAutoHeight = true;
ResetShowCount();
if (m_columns != null && m_columns.Count > 0) if (m_columns != null && m_columns.Count > 0)
ReloadSource(); ReloadSource();
} }
} }
/// <summary>
/// Gets or sets a value indicating whether [automatic rows scroll].
/// </summary>
/// <value><c>true</c> if [automatic rows scroll]; otherwise, <c>false</c>.</value>
[Description("行是否显示滚动条"), Category("自定义")]
public bool AutoRowsScroll
{
get
{
return this.panRow.AutoScroll;
}
set
{
this.panRow.AutoScroll = value;
}
}
/// <summary> /// <summary>
/// The m select row /// The m select row
/// </summary> /// </summary>
...@@ -368,73 +335,7 @@ namespace HZH_Controls.Controls ...@@ -368,73 +335,7 @@ namespace HZH_Controls.Controls
} }
return null; return null;
} }
/// <summary>
/// The m page
/// </summary>
private UCPagerControlBase m_page = null;
/// <summary>
/// 翻页控件
/// </summary>
/// <value>The page.</value>
/// <exception cref="Exception">翻页控件没有继承UCPagerControlBase</exception>
/// <exception cref="System.Exception">翻页控件没有继承UCPagerControlBase</exception>
[Description("翻页控件,如果UCPagerControl不满足你的需求,请自定义翻页控件并继承UCPagerControlBase"), Category("自定义")]
public UCPagerControlBase Page
{
get { return m_page; }
set
{
m_page = value;
if (value != null)
{
if (!typeof(IPageControl).IsAssignableFrom(value.GetType()) || !value.GetType().IsSubclassOf(typeof(UCPagerControlBase)))
throw new Exception("翻页控件没有继承UCPagerControlBase");
panPage.Visible = value != null;
m_page.ShowSourceChanged += page_ShowSourceChanged;
m_page.Dock = DockStyle.Fill;
//this.panPage.Height = value.Height;
this.panPage.Controls.Clear();
this.panPage.Controls.Add(m_page);
ResetShowCount();
m_page.PageSize = ShowCount;
this.DataSource = m_page.GetCurrentSource();
}
else
{
m_page = null;
}
}
}
/// <summary>
/// The m is automatic height
/// </summary>
private bool m_isCloseAutoHeight = false;
/// <summary>
/// 自动适应最大高度(当为true时,需要手动计算高度,请慎用)
/// </summary>
/// <value><c>true</c> if this instance is automatic height; otherwise, <c>false</c>.</value>
[Browsable(false)]
public bool IsCloseAutoHeight
{
get { return m_isCloseAutoHeight; }
set
{
m_isCloseAutoHeight = value;
this.AutoScroll = value;
}
}
/// <summary>
/// Pages the show source changed.
/// </summary>
/// <param name="currentSource">The current source.</param>
void page_ShowSourceChanged(object currentSource)
{
this.DataSource = currentSource;
}
#region 事件 #region 事件
/// <summary> /// <summary>
/// The head CheckBox change event /// The head CheckBox change event
...@@ -554,25 +455,6 @@ namespace HZH_Controls.Controls ...@@ -554,25 +455,6 @@ namespace HZH_Controls.Controls
} }
#endregion #endregion
/// <summary>
/// 功能描述:获取显示个数
/// 作  者:HZH
/// 创建日期:2019-03-05 10:02:58
/// 任务编号:POS
/// </summary>
/// <returns>返回值</returns>
public void ResetShowCount()
{
if (DesignMode)
{ return; }
if (this.Height <= 0)
return;
ShowCount = this.panRow.Height / (m_rowHeight);
if (ShowCount == 0)
return;
int intCha = this.panRow.Height % (m_rowHeight);
m_rowHeight += intCha / ShowCount;
}
#endregion #endregion
#region 公共函数 #region 公共函数
...@@ -585,16 +467,14 @@ namespace HZH_Controls.Controls ...@@ -585,16 +467,14 @@ namespace HZH_Controls.Controls
{ return; } { return; }
try try
{ {
ControlHelper.FreezeControl(this.panRow, true); ControlHelper.FreezeControl(this, true);
//this.panRow.Controls.Clear();
Rows = new List<IDataGridViewRow>(); Rows = new List<IDataGridViewRow>();
if (m_columns == null || m_columns.Count <= 0) if (m_columns == null || m_columns.Count <= 0)
return; return;
if (m_dataSource != null) if (m_dataSource != null)
{ {
int intIndex = 0; int intIndex = 0;
Control lastItem = null;
int intSourceCount = 0; int intSourceCount = 0;
if (m_dataSource is DataTable) if (m_dataSource is DataTable)
{ {
...@@ -628,15 +508,14 @@ namespace HZH_Controls.Controls ...@@ -628,15 +508,14 @@ namespace HZH_Controls.Controls
row.RowHeight = m_rowHeight; row.RowHeight = m_rowHeight;
item.Visible = true; item.Visible = true;
item.BringToFront(); item.BringToFront();
if (lastItem == null)
lastItem = item;
Rows.Add(row); Rows.Add(row);
} }
intIndex++; intIndex++;
} }
if (intIndex < intSourceCount) if (intIndex < intSourceCount)
{ {
for (int i = intIndex; i < intSourceCount; i++) for (int i = intIndex; i < intSourceCount; i++)
{ {
IDataGridViewRow row = (IDataGridViewRow)Activator.CreateInstance(m_rowType); IDataGridViewRow row = (IDataGridViewRow)Activator.CreateInstance(m_rowType);
...@@ -655,25 +534,19 @@ namespace HZH_Controls.Controls ...@@ -655,25 +534,19 @@ namespace HZH_Controls.Controls
row.BindingCellData(); row.BindingCellData();
Control rowControl = (row as Control); Control rowControl = (row as Control);
this.panRow.Controls.Add(rowControl);
row.RowHeight = m_rowHeight; row.RowHeight = m_rowHeight;
rowControl.Dock = DockStyle.Top; rowControl.Dock = DockStyle.Top;
row.CellClick += (a, b) => { SetSelectRow(rowControl, b); }; row.CellClick += (a, b) => { SetSelectRow(rowControl, b); };
row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); }; row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); };
row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } }; row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } };
row.SourceChanged += RowSourceChanged; row.SourceChanged += RowSourceChanged;
rowControl.BringToFront();
Rows.Add(row); Rows.Add(row);
this.panRow.Controls.Add(rowControl);
if (lastItem == null) rowControl.BringToFront();
lastItem = rowControl;
} }
} }
if (lastItem != null && intSourceCount == m_showCount)
{
lastItem.Height = this.panRow.Height - (m_showCount - 1) * m_rowHeight - 2;
}
} }
else else
{ {
...@@ -685,34 +558,10 @@ namespace HZH_Controls.Controls ...@@ -685,34 +558,10 @@ namespace HZH_Controls.Controls
} }
finally finally
{ {
ControlHelper.FreezeControl(this.panRow, false); ControlHelper.FreezeControl(this, false);
} }
} }
//void rowControl_SizeChanged(object sender, EventArgs e)
//{
// if (m_isAutoHeight)
// {
// int intHeightCount = 0;
// intHeightCount += (IsShowHead ? this.panHead.Height : 0) + (Page != null ? this.panPage.Height : 0);
// foreach (Control item in this.panRow.Controls)
// {
// intHeightCount += item.Height;
// }
// if (this.Parent.Name == "panChildGrid")
// {
// if (this.Parent.Height != intHeightCount)
// this.Parent.Height = intHeightCount;
// }
// else
// {
// if (this.Height != intHeightCount)
// this.Height = intHeightCount;
// }
// }
//}
/// <summary> /// <summary>
/// 快捷键 /// 快捷键
/// </summary> /// </summary>
...@@ -856,35 +705,8 @@ namespace HZH_Controls.Controls ...@@ -856,35 +705,8 @@ namespace HZH_Controls.Controls
ControlHelper.FreezeControl(this, false); ControlHelper.FreezeControl(this, false);
} }
} }
/// <summary>
/// Handles the Resize event of the UCDataGridView control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void UCDataGridView_Resize(object sender, EventArgs e)
{
if (this.Height <= 0)
return;
if (m_isCloseAutoHeight)
return;
ResetShowCount();
ReloadSource();
}
#endregion #endregion
/// <summary>
/// Handles the SizeChanged event of the panRow control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void panRow_SizeChanged(object sender, EventArgs e)
{
//if (m_isAutoHeight)
//{
// int intHeightCount = (IsShowHead ? this.panHead.Height : 0) + (Page != null ? this.panPage.Height : 0) + panRow.Height;
// if (this.Height != intHeightCount)
// this.Height = intHeightCount;
//}
}
} }
} }
...@@ -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.Designer.cs"> // <copyright file="UCPagerControl.Designer.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.
// *********************************************************************** // ***********************************************************************
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" />
partial class UCPagerControl partial class UCPagerControl
{ {
/// <summary> /// <summary>
/// 必需的设计器变量。 /// 必需的设计器变量。
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// 清理所有正在使用的资源。 /// 清理所有正在使用的资源。
/// </summary> /// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region 组件设计器生成的代码 #region 组件设计器生成的代码
/// <summary> /// <summary>
/// 设计器支持所需的方法 - 不要 /// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。 /// 使用代码编辑器修改此方法的内容。
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel4 = new System.Windows.Forms.Panel(); this.panel4 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
this.tableLayoutPanel1.ColumnCount = 4; this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.Controls.Add(this.panel4, 3, 0); this.tableLayoutPanel1.Controls.Add(this.panel4, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0); this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0); this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0); this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3); this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(304, 58); this.tableLayoutPanel1.Size = new System.Drawing.Size(304, 58);
this.tableLayoutPanel1.TabIndex = 1; this.tableLayoutPanel1.TabIndex = 1;
// //
// panel4 // panel4
// //
this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end; this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end;
this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel4.Location = new System.Drawing.Point(228, 6); this.panel4.Location = new System.Drawing.Point(228, 6);
this.panel4.Name = "panel4"; this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(68, 46); this.panel4.Size = new System.Drawing.Size(68, 46);
this.panel4.TabIndex = 3; this.panel4.TabIndex = 3;
this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown); this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown);
// //
// panel3 // panel3
// //
this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first; this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first;
this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel3.Location = new System.Drawing.Point(6, 6); this.panel3.Location = new System.Drawing.Point(6, 6);
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(68, 46); this.panel3.Size = new System.Drawing.Size(68, 46);
this.panel3.TabIndex = 2; this.panel3.TabIndex = 2;
this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown); this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown);
// //
// panel2 // panel2
// //
this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right; this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel2.Location = new System.Drawing.Point(154, 6); this.panel2.Location = new System.Drawing.Point(154, 6);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(68, 46); this.panel2.Size = new System.Drawing.Size(68, 46);
this.panel2.TabIndex = 1; this.panel2.TabIndex = 1;
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown); this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown);
// //
// panel1 // panel1
// //
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left; this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Location = new System.Drawing.Point(80, 6); this.panel1.Location = new System.Drawing.Point(80, 6);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(68, 46); this.panel1.Size = new System.Drawing.Size(68, 46);
this.panel1.TabIndex = 0; this.panel1.TabIndex = 0;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown); this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
// //
// UCPagerControl // UCPagerControl
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.tableLayoutPanel1);
this.Name = "UCPagerControl"; this.Name = "UCPagerControl";
this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion
/// <summary> /// <summary>
/// The table layout panel1 /// The table layout panel1
/// </summary> /// </summary>
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
/// <summary> /// <summary>
/// The panel4 /// The panel4
/// </summary> /// </summary>
private System.Windows.Forms.Panel panel4; private System.Windows.Forms.Panel panel4;
/// <summary> /// <summary>
/// The panel3 /// The panel3
/// </summary> /// </summary>
private System.Windows.Forms.Panel panel3; private System.Windows.Forms.Panel panel3;
/// <summary> /// <summary>
/// The panel2 /// The panel2
/// </summary> /// </summary>
private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Panel panel2;
/// <summary> /// <summary>
/// The panel1 /// The panel1
/// </summary> /// </summary>
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
} }
} }
// *********************************************************************** // ***********************************************************************
// 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;
}
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -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);
}
} }
} }
} }
......
// *********************************************************************** // ***********************************************************************
// Assembly : HZH_Controls // Assembly : HZH_Controls
// Created : 08-08-2019 // Created : 08-08-2019
// //
// *********************************************************************** // ***********************************************************************
// <copyright file="UCPagerControlBase.cs"> // <copyright file="UCPagerControlBase.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 UCPagerControlBase. /// Class UCPagerControlBase.
/// Implements the <see cref="System.Windows.Forms.UserControl" /> /// Implements the <see cref="System.Windows.Forms.UserControl" />
/// Implements the <see cref="HZH_Controls.Controls.IPageControl" /> /// Implements the <see cref="HZH_Controls.Controls.IPageControl" />
/// </summary> /// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" /> /// <seealso cref="System.Windows.Forms.UserControl" />
/// <seealso cref="HZH_Controls.Controls.IPageControl" /> /// <seealso cref="HZH_Controls.Controls.IPageControl" />
[ToolboxItem(false)] [ToolboxItem(false)]
public class UCPagerControlBase : UserControl, IPageControl public class UCPagerControlBase : UserControl, IPageControl
{ {
#region 构造 #region 构造
/// <summary> /// <summary>
/// 必需的设计器变量。 /// 必需的设计器变量。
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// 清理所有正在使用的资源。 /// 清理所有正在使用的资源。
/// </summary> /// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region 组件设计器生成的代码 #region 组件设计器生成的代码
/// <summary> /// <summary>
/// 设计器支持所需的方法 - 不要 /// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。 /// 使用代码编辑器修改此方法的内容。
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.SuspendLayout(); this.SuspendLayout();
// //
// UCPagerControlBase // UCPagerControlBase
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "UCPagerControlBase"; this.Name = "UCPagerControlBase";
this.Size = new System.Drawing.Size(304, 58); this.Size = new System.Drawing.Size(304, 58);
this.Load += new System.EventHandler(this.UCPagerControlBase_Load); this.Load += new System.EventHandler(this.UCPagerControlBase_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
#endregion #endregion
#endregion #endregion
/// <summary> private PageModel m_pm = PageModel.Soure;
/// 总页数 /// <summary>
/// </summary> /// 翻页控件模式
/// <value>The page count.</value> /// </summary>
public virtual int PageCount /// <value>The page model.</value>
{ public PageModel PageModel
get; {
set; get { return m_pm; }
} set { m_pm = value; }
/// <summary> }
/// The m page index
/// </summary> /// <summary>
private int m_pageIndex = 1; /// 总页数
/// <summary> /// </summary>
/// 当前页码 /// <value>The page count.</value>
/// </summary> public virtual int PageCount
/// <value>The index of the page.</value> {
public virtual int PageIndex get;
{ set;
get { return m_pageIndex; } }
set { m_pageIndex = value; } /// <summary>
} /// The m page index
private List<object> dataSource; /// </summary>
/// <summary> private int m_pageIndex = 1;
/// 关联的数据源 /// <summary>
/// </summary> /// 当前页码
/// <value>The data source.</value> /// </summary>
public virtual List<object> DataSource /// <value>The index of the page.</value>
{ public virtual int PageIndex
get { return dataSource; } {
set get { return m_pageIndex; }
{ set { m_pageIndex = value; }
dataSource = value; }
} private List<object> dataSource;
} /// <summary>
/// <summary> /// 关联的数据源
/// 数据源改变时发生 /// </summary>
/// </summary> /// <value>The data source.</value>
public virtual event PageControlEventHandler ShowSourceChanged; public virtual List<object> DataSource
/// <summary> {
/// The m page size get { return dataSource; }
/// </summary> set
private int m_pageSize = 1; {
/// <summary> dataSource = value;
/// 每页显示数量 }
/// </summary> }
/// <value>The size of the page.</value> /// <summary>
[Description("每页显示数量"), Category("自定义")] /// 数据源改变时发生
public virtual int PageSize /// </summary>
{ public virtual event PageControlEventHandler ShowSourceChanged;
get { return m_pageSize; } /// <summary>
set { m_pageSize = value; } /// The m page size
} /// </summary>
/// <summary> private int m_pageSize = 10;
/// The start index /// <summary>
/// </summary> /// 每页显示数量
private int startIndex = 0; /// </summary>
/// <summary> /// <value>The size of the page.</value>
/// 开始的下标 [Description("每页显示数量"), Category("自定义")]
/// </summary> public virtual int PageSize
/// <value>The start index.</value> {
[Description("开始的下标"), Category("自定义")] get { return m_pageSize; }
public virtual int StartIndex set { m_pageSize = value; }
{ }
get { return startIndex; } /// <summary>
set /// The start index
{ /// </summary>
startIndex = value; private int startIndex = 0;
if (startIndex <= 0) /// <summary>
startIndex = 0; /// 开始的下标
} /// </summary>
} /// <value>The start index.</value>
[Description("开始的下标"), Category("自定义")]
/// <summary> public virtual int StartIndex
/// Initializes a new instance of the <see cref="UCPagerControlBase" /> class. {
/// </summary> get { return startIndex; }
public UCPagerControlBase() set
{ {
InitializeComponent(); startIndex = value;
} if (startIndex <= 0)
startIndex = 0;
/// <summary> }
/// Handles the Load event of the UCPagerControlBase control. }
/// </summary>
/// <param name="sender">The source of the event.</param> /// <summary>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> /// Initializes a new instance of the <see cref="UCPagerControlBase" /> class.
private void UCPagerControlBase_Load(object sender, EventArgs e) /// </summary>
{ public UCPagerControlBase()
if (DataSource == null) {
ShowBtn(false, false); InitializeComponent();
else }
{
ShowBtn(false, DataSource.Count > PageSize); /// <summary>
} /// Handles the Load event of the UCPagerControlBase control.
} /// </summary>
/// <summary> /// <param name="sender">The source of the event.</param>
/// 第一页 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
/// </summary> private void UCPagerControlBase_Load(object sender, EventArgs e)
public virtual void FirstPage() {
{ if (PageModel == HZH_Controls.Controls.PageModel.Soure)
startIndex = 0; {
var s = GetCurrentSource(); if (DataSource == null)
ShowBtn(false, false);
if (ShowSourceChanged != null) else
{ {
ShowSourceChanged(s); ShowBtn(false, DataSource.Count > PageSize);
} }
} }
/// <summary> else
/// 上一页 {
/// </summary> if (PageCount <= 1)
public virtual void PreviousPage() {
{ ShowBtn(false, false);
if (startIndex == 0) }
return; else
startIndex -= m_pageSize; {
if (startIndex < 0) ShowBtn(false, PageCount > 1);
startIndex = 0; }
var s = GetCurrentSource(); }
}
if (ShowSourceChanged != null) /// <summary>
{ /// 第一页
ShowSourceChanged(s); /// </summary>
} public virtual void FirstPage()
} {
/// <summary> if (PageModel == HZH_Controls.Controls.PageModel.Soure)
/// 下一页 {
/// </summary> startIndex = 0;
public virtual void NextPage() var s = GetCurrentSource();
{
if (ShowSourceChanged != null)
if (startIndex + m_pageSize >= DataSource.Count) {
{ ShowSourceChanged(s);
return; }
} }
startIndex += m_pageSize; else
if (startIndex < 0) {
startIndex = 0; startIndex = 0;
var s = GetCurrentSource(); PageIndex = 1;
SetShow();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(this);
} }
} }
/// <summary> }
/// 最后一页 /// <summary>
/// </summary> /// 上一页
public virtual void EndPage() /// </summary>
{ public virtual void PreviousPage()
if (DataSource == null) {
{ if (PageModel == HZH_Controls.Controls.PageModel.Soure)
if (ShowSourceChanged != null) {
{ if (startIndex == 0)
ShowSourceChanged(null); return;
} startIndex -= m_pageSize;
return; if (startIndex < 0)
} startIndex = 0;
startIndex = DataSource.Count - m_pageSize; var s = GetCurrentSource();
if (startIndex < 0)
startIndex = 0; if (ShowSourceChanged != null)
var s = GetCurrentSource(); {
ShowSourceChanged(s);
if (ShowSourceChanged != null) }
{ }
ShowSourceChanged(s); else
} {
} if (PageIndex <= 1)
/// <summary> return;
/// 刷新数据 PageIndex--;
/// </summary> SetShow();
public virtual void Reload() if (ShowSourceChanged != null)
{ {
var s = GetCurrentSource(); ShowSourceChanged(this);
if (ShowSourceChanged != null) }
{ }
ShowSourceChanged(s); }
} /// <summary>
} /// 下一页
/// <summary> /// </summary>
/// 获取当前页数据 public virtual void NextPage()
/// </summary> {
/// <returns>List&lt;System.Object&gt;.</returns> if (PageModel == HZH_Controls.Controls.PageModel.Soure)
public virtual List<object> GetCurrentSource() {
{ if (startIndex + m_pageSize >= DataSource.Count)
if (DataSource == null || DataSource.Count <= 0) {
return null; return;
int intShowCount = m_pageSize; }
if (intShowCount + startIndex > DataSource.Count) startIndex += m_pageSize;
intShowCount = DataSource.Count - startIndex; if (startIndex < 0)
object[] objs = new object[intShowCount]; startIndex = 0;
DataSource.CopyTo(startIndex, objs, 0, intShowCount); var s = GetCurrentSource();
var lst = objs.ToList();
if (ShowSourceChanged != null)
bool blnLeft = false; {
bool blnRight = false; ShowSourceChanged(s);
if (lst.Count > 0) }
{ }
if (DataSource.IndexOf(lst[0]) > 0) else
{ {
blnLeft = true; if (PageIndex >= PageCount)
} return;
else PageIndex++;
{ SetShow();
blnLeft = false; if (ShowSourceChanged != null)
} {
if (DataSource.IndexOf(lst[lst.Count - 1]) >= DataSource.Count - 1) ShowSourceChanged(this);
{ }
blnRight = false; }
} }
else /// <summary>
{ /// 最后一页
blnRight = true; /// </summary>
} public virtual void EndPage()
} {
ShowBtn(blnLeft, blnRight); if (PageModel == HZH_Controls.Controls.PageModel.Soure)
return lst; {
} if (DataSource == null)
{
/// <summary> if (ShowSourceChanged != null)
/// 控制按钮显示 {
/// </summary> ShowSourceChanged(null);
/// <param name="blnLeftBtn">是否显示上一页,第一页</param> }
/// <param name="blnRightBtn">是否显示下一页,最后一页</param> return;
protected virtual void ShowBtn(bool blnLeftBtn, bool blnRightBtn) }
{ } startIndex = DataSource.Count - m_pageSize;
} if (startIndex < 0)
} startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
PageIndex = PageCount;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary>
/// 刷新数据
/// </summary>
public virtual void Reload()
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns>List&lt;System.Object&gt;.</returns>
public virtual List<object> GetCurrentSource()
{
if (DataSource == null || DataSource.Count <= 0)
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)
{ }
private void SetShow()
{
bool blnLeft = false;
bool blnRight = false;
if (PageCount > 0)
{
if (PageIndex > 1)
{
blnLeft = true;
}
else
{
blnLeft = false;
}
if (PageIndex >= PageCount)
{
blnRight = false;
}
else
{
blnRight = true;
}
}
ShowBtn(blnLeft, blnRight);
}
}
}
...@@ -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!