Commit 083a6d02 HZH

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

1 个父辈 34925690
正在显示 27 个修改的文件 包含 440 行增加303 行删除
...@@ -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,10 +93,6 @@ namespace HZH_Controls.Controls ...@@ -93,10 +93,6 @@ 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.
...@@ -104,12 +100,13 @@ namespace HZH_Controls.Controls ...@@ -104,12 +100,13 @@ namespace HZH_Controls.Controls
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;
if (m_page != null)
{ {
m_page.PageSize = value; return this.panRow.Height / (m_rowHeight);
}
} }
} }
...@@ -264,32 +251,12 @@ namespace HZH_Controls.Controls ...@@ -264,32 +251,12 @@ namespace HZH_Controls.Controls
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> /// <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>
/// The m select row /// The m select row
/// </summary> /// </summary>
IDataGridViewRow m_selectRow = null; IDataGridViewRow m_selectRow = null;
...@@ -369,72 +336,6 @@ namespace HZH_Controls.Controls ...@@ -369,72 +336,6 @@ 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,15 +467,13 @@ namespace HZH_Controls.Controls ...@@ -585,15 +467,13 @@ 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,8 +508,7 @@ namespace HZH_Controls.Controls ...@@ -628,8 +508,7 @@ 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++;
...@@ -656,24 +535,18 @@ namespace HZH_Controls.Controls ...@@ -656,24 +535,18 @@ namespace HZH_Controls.Controls
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);
rowControl.BringToFront();
if (lastItem == null)
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,6 +159,8 @@ namespace HZH_Controls.Controls ...@@ -160,6 +159,8 @@ 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 != null)
{
if (this.Parent.Parent.Parent != null && this.Parent.Parent.Parent.Name == "panChildGrid" && this.panLeft.Tag.ToInt() == 1) if (this.Parent.Parent.Parent != null && this.Parent.Parent.Parent.Name == "panChildGrid" && this.panLeft.Tag.ToInt() == 1)
{ {
int intHeight = this.Parent.Parent.Controls[0].Controls.ToArray().Sum(p => p.Height); int intHeight = this.Parent.Parent.Controls[0].Controls.ToArray().Sum(p => p.Height);
...@@ -167,6 +168,7 @@ namespace HZH_Controls.Controls ...@@ -167,6 +168,7 @@ namespace HZH_Controls.Controls
this.Parent.Parent.Parent.Height = intHeight; this.Parent.Parent.Parent.Height = intHeight;
} }
} }
}
/// <summary> /// <summary>
...@@ -307,6 +309,8 @@ namespace HZH_Controls.Controls ...@@ -307,6 +309,8 @@ namespace HZH_Controls.Controls
box.CheckedChangeEvent += (a, b) => box.CheckedChangeEvent += (a, b) =>
{ {
IsChecked = box.Checked; IsChecked = box.Checked;
if (this.ucDGVChild.Rows != null)
{
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked); this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked);
if (CheckBoxChangeEvent != null) if (CheckBoxChangeEvent != null)
{ {
...@@ -316,6 +320,7 @@ namespace HZH_Controls.Controls ...@@ -316,6 +320,7 @@ namespace HZH_Controls.Controls
CellIndex = 0 CellIndex = 0
}); });
} }
}
}; };
c = box; c = box;
} }
......
...@@ -79,5 +79,6 @@ namespace HZH_Controls.Controls ...@@ -79,5 +79,6 @@ namespace HZH_Controls.Controls
/// </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; }
} }
} }
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
}
}
...@@ -32,6 +32,45 @@ namespace HZH_Controls.Controls ...@@ -32,6 +32,45 @@ namespace HZH_Controls.Controls
[ToolboxItem(true)] [ToolboxItem(true)]
public partial class UCPagerControl : UCPagerControlBase public partial class UCPagerControl : UCPagerControlBase
{ {
public override int PageCount
{
get
{
return base.PageCount;
}
set
{
base.PageCount = value;
if (PageCount <= 1)
{
ShowBtn(false, false);
}
else
{
ShowBtn(false, PageCount > 1);
}
}
}
public override int PageIndex
{
get
{
return base.PageIndex;
}
set
{
base.PageIndex = value;
if (PageCount <= 1)
{
ShowBtn(false, false);
}
else
{
ShowBtn(false, PageCount > 1);
}
}
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UCPagerControl" /> class. /// Initializes a new instance of the <see cref="UCPagerControl" /> class.
/// </summary> /// </summary>
...@@ -90,5 +129,7 @@ namespace HZH_Controls.Controls ...@@ -90,5 +129,7 @@ namespace HZH_Controls.Controls
panel1.Visible = panel3.Visible = blnLeftBtn; panel1.Visible = panel3.Visible = blnLeftBtn;
panel2.Visible = panel4.Visible = blnRightBtn; panel2.Visible = panel4.Visible = blnRightBtn;
} }
} }
} }
...@@ -105,6 +105,8 @@ namespace HZH_Controls.Controls ...@@ -105,6 +105,8 @@ namespace HZH_Controls.Controls
set set
{ {
base.PageSize = value; base.PageSize = value;
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
ResetPageCount(); ResetPageCount();
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
...@@ -112,6 +114,40 @@ namespace HZH_Controls.Controls ...@@ -112,6 +114,40 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); 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();
}
} }
/// <summary> /// <summary>
...@@ -122,14 +158,24 @@ namespace HZH_Controls.Controls ...@@ -122,14 +158,24 @@ namespace HZH_Controls.Controls
if (PageIndex == 1) if (PageIndex == 1)
return; return;
PageIndex = 1; PageIndex = 1;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 上一页 /// 上一页
...@@ -141,15 +187,24 @@ namespace HZH_Controls.Controls ...@@ -141,15 +187,24 @@ namespace HZH_Controls.Controls
return; return;
} }
PageIndex--; PageIndex--;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 下一页 /// 下一页
...@@ -161,14 +216,24 @@ namespace HZH_Controls.Controls ...@@ -161,14 +216,24 @@ namespace HZH_Controls.Controls
return; return;
} }
PageIndex++; PageIndex++;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 最后一页 /// 最后一页
...@@ -178,14 +243,24 @@ namespace HZH_Controls.Controls ...@@ -178,14 +243,24 @@ namespace HZH_Controls.Controls
if (PageIndex == PageCount) if (PageIndex == PageCount)
return; return;
PageIndex = PageCount; PageIndex = PageCount;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
StartIndex = (PageIndex - 1) * PageSize;
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// Resets the page count. /// Resets the page count.
...@@ -318,6 +393,8 @@ namespace HZH_Controls.Controls ...@@ -318,6 +393,8 @@ 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();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
...@@ -325,6 +402,14 @@ namespace HZH_Controls.Controls ...@@ -325,6 +402,14 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 控制按钮显示 /// 控制按钮显示
...@@ -389,12 +474,22 @@ namespace HZH_Controls.Controls ...@@ -389,12 +474,22 @@ namespace HZH_Controls.Controls
PageIndex = txtPage.InputText.ToInt(); PageIndex = txtPage.InputText.ToInt();
StartIndex = (PageIndex - 1) * PageSize; StartIndex = (PageIndex - 1) * PageSize;
ReloadPage(); ReloadPage();
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
} }
} }
......
...@@ -75,6 +75,17 @@ namespace HZH_Controls.Controls ...@@ -75,6 +75,17 @@ namespace HZH_Controls.Controls
#endregion #endregion
#endregion #endregion
private PageModel m_pm = PageModel.Soure;
/// <summary>
/// 翻页控件模式
/// </summary>
/// <value>The page model.</value>
public PageModel PageModel
{
get { return m_pm; }
set { m_pm = value; }
}
/// <summary> /// <summary>
/// 总页数 /// 总页数
/// </summary> /// </summary>
...@@ -117,7 +128,7 @@ namespace HZH_Controls.Controls ...@@ -117,7 +128,7 @@ namespace HZH_Controls.Controls
/// <summary> /// <summary>
/// The m page size /// The m page size
/// </summary> /// </summary>
private int m_pageSize = 1; private int m_pageSize = 10;
/// <summary> /// <summary>
/// 每页显示数量 /// 每页显示数量
/// </summary> /// </summary>
...@@ -163,6 +174,8 @@ namespace HZH_Controls.Controls ...@@ -163,6 +174,8 @@ 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>
private void UCPagerControlBase_Load(object sender, EventArgs e) private void UCPagerControlBase_Load(object sender, EventArgs e)
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (DataSource == null) if (DataSource == null)
ShowBtn(false, false); ShowBtn(false, false);
else else
...@@ -170,11 +183,25 @@ namespace HZH_Controls.Controls ...@@ -170,11 +183,25 @@ namespace HZH_Controls.Controls
ShowBtn(false, DataSource.Count > PageSize); ShowBtn(false, DataSource.Count > PageSize);
} }
} }
else
{
if (PageCount <= 1)
{
ShowBtn(false, false);
}
else
{
ShowBtn(false, PageCount > 1);
}
}
}
/// <summary> /// <summary>
/// 第一页 /// 第一页
/// </summary> /// </summary>
public virtual void FirstPage() public virtual void FirstPage()
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
startIndex = 0; startIndex = 0;
var s = GetCurrentSource(); var s = GetCurrentSource();
...@@ -183,11 +210,24 @@ namespace HZH_Controls.Controls ...@@ -183,11 +210,24 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
startIndex = 0;
PageIndex = 1;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 上一页 /// 上一页
/// </summary> /// </summary>
public virtual void PreviousPage() public virtual void PreviousPage()
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (startIndex == 0) if (startIndex == 0)
return; return;
startIndex -= m_pageSize; startIndex -= m_pageSize;
...@@ -200,12 +240,25 @@ namespace HZH_Controls.Controls ...@@ -200,12 +240,25 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (PageIndex <= 1)
return;
PageIndex--;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 下一页 /// 下一页
/// </summary> /// </summary>
public virtual void NextPage() public virtual void NextPage()
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (startIndex + m_pageSize >= DataSource.Count) if (startIndex + m_pageSize >= DataSource.Count)
{ {
return; return;
...@@ -220,11 +273,25 @@ namespace HZH_Controls.Controls ...@@ -220,11 +273,25 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (PageIndex >= PageCount)
return;
PageIndex++;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 最后一页 /// 最后一页
/// </summary> /// </summary>
public virtual void EndPage() public virtual void EndPage()
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (DataSource == null) if (DataSource == null)
{ {
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
...@@ -243,17 +310,37 @@ namespace HZH_Controls.Controls ...@@ -243,17 +310,37 @@ namespace HZH_Controls.Controls
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
PageIndex = PageCount;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 刷新数据 /// 刷新数据
/// </summary> /// </summary>
public virtual void Reload() public virtual void Reload()
{ {
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
var s = GetCurrentSource(); var s = GetCurrentSource();
if (ShowSourceChanged != null) if (ShowSourceChanged != null)
{ {
ShowSourceChanged(s); ShowSourceChanged(s);
} }
} }
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary> /// <summary>
/// 获取当前页数据 /// 获取当前页数据
/// </summary> /// </summary>
...@@ -301,5 +388,31 @@ namespace HZH_Controls.Controls ...@@ -301,5 +388,31 @@ namespace HZH_Controls.Controls
/// <param name="blnRightBtn">是否显示下一页,最后一页</param> /// <param name="blnRightBtn">是否显示下一页,最后一页</param>
protected virtual void ShowBtn(bool blnLeftBtn, bool blnRightBtn) 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)
{ {
...@@ -52,11 +42,7 @@ namespace Test.UC ...@@ -52,11 +42,7 @@ namespace Test.UC
}; };
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);
......
...@@ -16,18 +16,8 @@ namespace Test.UC ...@@ -16,18 +16,8 @@ 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!