Commit b60631b4 leo GitHub 提交于

Merge pull request #4 from kwwwvagaa/master

同步
2 个父辈 1b7ef398 8b7440ef
正在显示 47 个修改的文件 包含 2146 行增加1195 行删除
......@@ -78,6 +78,7 @@ namespace HZH_Controls.Controls
get { return _ForeColor; }
set
{
base.ForeColor = value;
label1.ForeColor = value;
_ForeColor = value;
}
......
......@@ -50,11 +50,12 @@ namespace HZH_Controls.Controls
{
this.components = new System.ComponentModel.Container();
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.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.timer1 = new System.Windows.Forms.Timer(this.components);
this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
......@@ -75,23 +76,11 @@ namespace HZH_Controls.Controls
this.panel1.Size = new System.Drawing.Size(447, 333);
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
//
this.ucControlBase1.ConerRadius = 5;
this.ucControlBase1.Controls.Add(this.ucDataGridView1);
this.ucControlBase1.Controls.Add(this.m_page);
this.ucControlBase1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucControlBase1.FillColor = System.Drawing.Color.Transparent;
this.ucControlBase1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
......@@ -109,6 +98,7 @@ namespace HZH_Controls.Controls
//
// ucDataGridView1
//
this.ucDataGridView1.AutoScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
......@@ -117,18 +107,37 @@ namespace HZH_Controls.Controls
this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 0;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(5, 5);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 30;
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.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
//
this.txtSearch.BackColor = System.Drawing.Color.Transparent;
......@@ -137,6 +146,7 @@ namespace HZH_Controls.Controls
this.txtSearch.DecLength = 2;
this.txtSearch.Dock = System.Windows.Forms.DockStyle.Top;
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.InputText = "";
this.txtSearch.InputType = HZH_Controls.TextInputType.NotControl;
......@@ -170,6 +180,11 @@ namespace HZH_Controls.Controls
this.txtSearch.Size = new System.Drawing.Size(437, 42);
this.txtSearch.TabIndex = 0;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// ucSplitLine_V2
//
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
/// The text search
/// </summary>
private UCTextBoxEx txtSearch;
private UCPagerControl m_page;
}
}
......@@ -93,23 +93,20 @@ namespace HZH_Controls.Controls
/// The string last search text
/// </summary>
private string strLastSearchText = string.Empty;
/// <summary>
/// The m page
/// </summary>
UCPagerControl m_page = new UCPagerControl();
/// <summary>
/// Initializes a new instance of the <see cref="UCComboxGridPanel" /> class.
/// </summary>
public UCComboxGridPanel()
{
InitializeComponent();
this.ucDataGridView1.Page = m_page;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.txtSearch.txtInput.TextChanged += txtInput_TextChanged;
this.ucDataGridView1.ItemClick += ucDataGridView1_ItemClick;
m_page.ShowSourceChanged += m_page_ShowSourceChanged;
}
/// <summary>
/// Handles the ItemClick event of the ucDataGridView1 control.
/// </summary>
......@@ -172,7 +169,7 @@ namespace HZH_Controls.Controls
m_page.StartIndex = 0;
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)));
m_page.DataSource = lst;
}
......@@ -182,5 +179,10 @@ namespace HZH_Controls.Controls
}
m_page.Reload();
}
void m_page_ShowSourceChanged(object currentSource)
{
this.ucDataGridView1.DataSource = currentSource;
}
}
}
......@@ -60,5 +60,23 @@ namespace HZH_Controls.Controls
/// </summary>
/// <value>The text align.</value>
public ContentAlignment TextAlign { get { return _TextAlign; } set { _TextAlign = value; } }
/// <summary>
/// 自定义的单元格控件,一个实现IDataGridViewCustomCell的Control
/// </summary>
/// <value>The custom cell.</value>
private Type customCellType = null;
public Type CustomCellType
{
get
{
return customCellType;
}
set
{
if (!typeof(IDataGridViewCustomCell).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(System.Windows.Forms.Control)))
throw new Exception("行控件没有实现IDataGridViewCustomCell接口");
customCellType = value;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Controls
{
public interface IDataGridViewCustomCell
{
/// <summary>
/// 绑定行关联的数据
/// </summary>
/// <param name="obj">The object.</param>
void SetBindSource(object obj);
}
}
......@@ -53,7 +53,6 @@ namespace HZH_Controls.Controls
this.panHeadLeft = new System.Windows.Forms.Panel();
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panRow = new System.Windows.Forms.Panel();
this.panPage = new System.Windows.Forms.Panel();
this.panHead.SuspendLayout();
this.SuspendLayout();
//
......@@ -105,18 +104,8 @@ namespace HZH_Controls.Controls
this.panRow.Dock = System.Windows.Forms.DockStyle.Fill;
this.panRow.Location = new System.Drawing.Point(0, 40);
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.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
//
......@@ -124,11 +113,9 @@ namespace HZH_Controls.Controls
this.AutoScroll = true;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.panRow);
this.Controls.Add(this.panPage);
this.Controls.Add(this.panHead);
this.Name = "UCDataGridView";
this.Size = new System.Drawing.Size(1061, 565);
this.Resize += new System.EventHandler(this.UCDataGridView_Resize);
this.panHead.ResumeLayout(false);
this.ResumeLayout(false);
......@@ -153,10 +140,6 @@ namespace HZH_Controls.Controls
/// </summary>
private System.Windows.Forms.Panel panRow;
/// <summary>
/// The pan page
/// </summary>
private System.Windows.Forms.Panel panPage;
/// <summary>
/// The pan head left
/// </summary>
private System.Windows.Forms.Panel panHeadLeft;
......
......@@ -98,11 +98,6 @@ namespace HZH_Controls.Controls
{
m_isShowHead = value;
panHead.Visible = value;
if (m_page != null)
{
ResetShowCount();
m_page.PageSize = m_showCount;
}
}
}
/// <summary>
......@@ -161,25 +156,17 @@ namespace HZH_Controls.Controls
set { m_rowHeight = value; }
}
/// <summary>
/// The m show count
/// </summary>
private int m_showCount = 0;
/// <summary>
/// Gets the show count.
/// </summary>
/// <value>The show count.</value>
[Description("可显示个数"), Category("自定义")]
[Description("当前高度可显示行个数"), Category("自定义")]
public int ShowCount
{
get { return m_showCount; }
private set
get
{
m_showCount = value;
if (m_page != null)
{
m_page.PageSize = value;
}
return this.panRow.Height / (m_rowHeight);
}
}
......@@ -263,32 +250,12 @@ namespace HZH_Controls.Controls
return;
if (!typeof(IDataGridViewRow).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(Control)))
throw new Exception("行控件没有实现IDataGridViewRow接口");
m_rowType = value;
if (value == typeof(UCDataGridViewTreeRow))
IsCloseAutoHeight = true;
ResetShowCount();
m_rowType = value;
if (m_columns != null && m_columns.Count > 0)
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>
/// The m select row
/// </summary>
......@@ -368,73 +335,7 @@ namespace HZH_Controls.Controls
}
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 事件
/// <summary>
/// The head CheckBox change event
......@@ -554,25 +455,6 @@ namespace HZH_Controls.Controls
}
#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
#region 公共函数
......@@ -585,16 +467,14 @@ namespace HZH_Controls.Controls
{ return; }
try
{
ControlHelper.FreezeControl(this.panRow, true);
//this.panRow.Controls.Clear();
ControlHelper.FreezeControl(this, true);
Rows = new List<IDataGridViewRow>();
if (m_columns == null || m_columns.Count <= 0)
return;
if (m_dataSource != null)
{
int intIndex = 0;
Control lastItem = null;
int intSourceCount = 0;
if (m_dataSource is DataTable)
{
......@@ -628,15 +508,14 @@ namespace HZH_Controls.Controls
row.RowHeight = m_rowHeight;
item.Visible = true;
item.BringToFront();
if (lastItem == null)
lastItem = item;
Rows.Add(row);
}
intIndex++;
}
if (intIndex < intSourceCount)
{
{
for (int i = intIndex; i < intSourceCount; i++)
{
IDataGridViewRow row = (IDataGridViewRow)Activator.CreateInstance(m_rowType);
......@@ -655,25 +534,19 @@ namespace HZH_Controls.Controls
row.BindingCellData();
Control rowControl = (row as Control);
this.panRow.Controls.Add(rowControl);
Control rowControl = (row as Control);
row.RowHeight = m_rowHeight;
rowControl.Dock = DockStyle.Top;
row.CellClick += (a, b) => { SetSelectRow(rowControl, b); };
row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); };
row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } };
row.SourceChanged += RowSourceChanged;
rowControl.BringToFront();
Rows.Add(row);
if (lastItem == null)
lastItem = rowControl;
this.panRow.Controls.Add(rowControl);
rowControl.BringToFront();
}
}
if (lastItem != null && intSourceCount == m_showCount)
{
lastItem.Height = this.panRow.Height - (m_showCount - 1) * m_rowHeight - 2;
}
}
}
else
{
......@@ -685,34 +558,10 @@ namespace HZH_Controls.Controls
}
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>
......@@ -856,35 +705,8 @@ namespace HZH_Controls.Controls
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
/// <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;
//}
}
}
}
......@@ -166,6 +166,14 @@ namespace HZH_Controls.Controls
}
}
}
}
}
foreach (Control item in this.panCells.Controls)
{
if (item is IDataGridViewCustomCell)
{
IDataGridViewCustomCell cell = item as IDataGridViewCustomCell;
cell.SetBindSource(DataSource);
}
}
}
......@@ -253,19 +261,28 @@ namespace HZH_Controls.Controls
var item = Columns[i - (IsShowCheckBox ? 1 : 0)];
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
Label lbl = new Label();
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
lbl.Name = "lbl_" + item.DataField;
lbl.Font = new Font("微软雅黑", 12);
lbl.ForeColor = Color.Black;
lbl.AutoSize = false;
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = item.TextAlign;
lbl.MouseDown += (a, b) =>
if (item.CustomCellType == null)
{
Item_MouseDown(a, b);
};
c = lbl;
Label lbl = new Label();
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
lbl.Name = "lbl_" + item.DataField;
lbl.Font = new Font("微软雅黑", 12);
lbl.ForeColor = Color.Black;
lbl.AutoSize = false;
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = item.TextAlign;
lbl.MouseDown += (a, b) =>
{
Item_MouseDown(a, b);
};
c = lbl;
}
else
{
Control cc = (Control)Activator.CreateInstance(item.CustomCellType);
cc.Dock = DockStyle.Fill;
c = cc;
}
}
this.panCells.Controls.Add(c, i, 0);
}
......
......@@ -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)
| System.Windows.Forms.AnchorStyles.Right)));
this.ucDGVChild.AutoRowsScroll = false;
this.ucDGVChild.BackColor = System.Drawing.Color.White;
this.ucDGVChild.Columns = null;
this.ucDGVChild.DataSource = null;
......@@ -109,12 +108,10 @@ namespace HZH_Controls.Controls
this.ucDGVChild.HeadHeight = 40;
this.ucDGVChild.HeadPadingLeft = 0;
this.ucDGVChild.HeadTextColor = System.Drawing.Color.Black;
this.ucDGVChild.IsCloseAutoHeight = false;
this.ucDGVChild.IsShowCheckBox = false;
this.ucDGVChild.IsShowHead = false;
this.ucDGVChild.Location = new System.Drawing.Point(25, 0);
this.ucDGVChild.Name = "ucDGVChild";
this.ucDGVChild.Page = null;
this.ucDGVChild.RowHeight = 40;
this.ucDGVChild.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDGVChild.Size = new System.Drawing.Size(636, 100);
......
......@@ -137,7 +137,6 @@ namespace HZH_Controls.Controls
{
InitializeComponent();
this.ucDGVChild.RowType = this.GetType();
this.ucDGVChild.IsCloseAutoHeight = true;
this.SizeChanged += UCDataGridViewTreeRow_SizeChanged;
this.ucDGVChild.ItemClick += (a, b) =>
{
......@@ -160,11 +159,14 @@ namespace HZH_Controls.Controls
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
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.Height != intHeight)
this.Parent.Parent.Parent.Height = intHeight;
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);
if (this.Parent.Parent.Parent.Height != intHeight)
this.Parent.Parent.Parent.Height = intHeight;
}
}
}
......@@ -196,6 +198,14 @@ namespace HZH_Controls.Controls
}
}
}
foreach (Control item in this.panCells.Controls)
{
if (item is IDataGridViewCustomCell)
{
IDataGridViewCustomCell cell = item as IDataGridViewCustomCell;
cell.SetBindSource(DataSource);
}
}
panLeft.Tag = 0;
var proChildrens = DataSource.GetType().GetProperty("Childrens");
if (proChildrens != null)
......@@ -307,14 +317,17 @@ namespace HZH_Controls.Controls
box.CheckedChangeEvent += (a, b) =>
{
IsChecked = box.Checked;
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked);
if (CheckBoxChangeEvent != null)
if (this.ucDGVChild.Rows != null)
{
CheckBoxChangeEvent(a, new DataGridViewEventArgs()
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked);
if (CheckBoxChangeEvent != null)
{
CellControl = box,
CellIndex = 0
});
CheckBoxChangeEvent(a, new DataGridViewEventArgs()
{
CellControl = box,
CellIndex = 0
});
}
}
};
c = box;
......@@ -324,19 +337,28 @@ namespace HZH_Controls.Controls
var item = Columns[i - (IsShowCheckBox ? 1 : 0)];
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
Label lbl = new Label();
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
lbl.Name = "lbl_" + item.DataField;
lbl.Font = new Font("微软雅黑", 12);
lbl.ForeColor = Color.Black;
lbl.AutoSize = false;
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = item.TextAlign;
lbl.MouseDown += (a, b) =>
if (item.CustomCellType == null)
{
Item_MouseDown(a, b);
};
c = lbl;
Label lbl = new Label();
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
lbl.Name = "lbl_" + item.DataField;
lbl.Font = new Font("微软雅黑", 12);
lbl.ForeColor = Color.Black;
lbl.AutoSize = false;
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = item.TextAlign;
lbl.MouseDown += (a, b) =>
{
Item_MouseDown(a, b);
};
c = lbl;
}
else
{
Control cc = (Control)Activator.CreateInstance(item.CustomCellType);
cc.Dock = DockStyle.Fill;
c = cc;
}
}
this.panCells.Controls.Add(c, i, 0);
}
......@@ -407,7 +429,7 @@ namespace HZH_Controls.Controls
}
}
else
{
{
Control[] cs = panChildGrid.Controls.Find("panLeft", true);
foreach (var item in cs)
......
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="IPageControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// Interface IPageControl
/// </summary>
public interface IPageControl
{
/// <summary>
/// 数据源改变时发生
/// </summary>
event PageControlEventHandler ShowSourceChanged;
/// <summary>
/// 数据源
/// </summary>
/// <value>The data source.</value>
List<object> DataSource { get; set; }
/// <summary>
/// 显示数量
/// </summary>
/// <value>The size of the page.</value>
int PageSize { get; set; }
/// <summary>
/// 开始下标
/// </summary>
/// <value>The start index.</value>
int StartIndex { get; set; }
/// <summary>
/// 第一页
/// </summary>
void FirstPage();
/// <summary>
/// 前一页
/// </summary>
void PreviousPage();
/// <summary>
/// 下一页
/// </summary>
void NextPage();
/// <summary>
/// 最后一页
/// </summary>
void EndPage();
/// <summary>
/// 重新加载
/// </summary>
void Reload();
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns>List&lt;System.Object&gt;.</returns>
List<object> GetCurrentSource();
/// <summary>
/// 总页数
/// </summary>
/// <value>The page count.</value>
int PageCount { get; set; }
/// <summary>
/// 当前页
/// </summary>
/// <value>The index of the page.</value>
int PageIndex { get; set; }
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="IPageControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// Interface IPageControl
/// </summary>
public interface IPageControl
{
/// <summary>
/// 数据源改变时发生
/// </summary>
event PageControlEventHandler ShowSourceChanged;
/// <summary>
/// 数据源
/// </summary>
/// <value>The data source.</value>
List<object> DataSource { get; set; }
/// <summary>
/// 显示数量
/// </summary>
/// <value>The size of the page.</value>
int PageSize { get; set; }
/// <summary>
/// 开始下标
/// </summary>
/// <value>The start index.</value>
int StartIndex { get; set; }
/// <summary>
/// 第一页
/// </summary>
void FirstPage();
/// <summary>
/// 前一页
/// </summary>
void PreviousPage();
/// <summary>
/// 下一页
/// </summary>
void NextPage();
/// <summary>
/// 最后一页
/// </summary>
void EndPage();
/// <summary>
/// 重新加载
/// </summary>
void Reload();
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns>List&lt;System.Object&gt;.</returns>
List<object> GetCurrentSource();
/// <summary>
/// 总页数
/// </summary>
/// <value>The page count.</value>
int PageCount { get; set; }
/// <summary>
/// 当前页
/// </summary>
/// <value>The index of the page.</value>
int PageIndex { get; set; }
PageModel PageModel { get; set; }
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="PageControlEventHandler.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// Delegate PageControlEventHandler
/// </summary>
/// <param name="currentSource">The current source.</param>
[Serializable]
[ComVisible(true)]
public delegate void PageControlEventHandler(object currentSource);
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="PageControlEventHandler.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace HZH_Controls.Controls
{
/// <summary>
/// Delegate PageControlEventHandler
/// </summary>
/// <param name="currentSource">The current source.</param>
[Serializable]
[ComVisible(true)]
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
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="UCPagerControl.Designer.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControl.
/// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
partial class UCPagerControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
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.Controls.Add(this.panel4, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 1;
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.TabIndex = 1;
//
// panel4
//
this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end;
this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel4.Location = new System.Drawing.Point(228, 6);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(68, 46);
this.panel4.TabIndex = 3;
this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown);
//
// panel3
//
this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first;
this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel3.Location = new System.Drawing.Point(6, 6);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(68, 46);
this.panel3.TabIndex = 2;
this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown);
//
// panel2
//
this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel2.Location = new System.Drawing.Point(154, 6);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(68, 46);
this.panel2.TabIndex = 1;
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown);
//
// panel1
//
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Location = new System.Drawing.Point(80, 6);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(68, 46);
this.panel1.TabIndex = 0;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// UCPagerControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "UCPagerControl";
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The table layout panel1
/// </summary>
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
/// <summary>
/// The panel4
/// </summary>
private System.Windows.Forms.Panel panel4;
/// <summary>
/// The panel3
/// </summary>
private System.Windows.Forms.Panel panel3;
/// <summary>
/// The panel2
/// </summary>
private System.Windows.Forms.Panel panel2;
/// <summary>
/// The panel1
/// </summary>
private System.Windows.Forms.Panel panel1;
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="UCPagerControl.Designer.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControl.
/// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
partial class UCPagerControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel3 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.panel1 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
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.Controls.Add(this.panel4, 3, 0);
this.tableLayoutPanel1.Controls.Add(this.panel3, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.panel2, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3);
this.tableLayoutPanel1.RowCount = 1;
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.TabIndex = 1;
//
// panel4
//
this.panel4.BackgroundImage = global::HZH_Controls.Properties.Resources.end;
this.panel4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel4.Location = new System.Drawing.Point(228, 6);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(68, 46);
this.panel4.TabIndex = 3;
this.panel4.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel4_MouseDown);
//
// panel3
//
this.panel3.BackgroundImage = global::HZH_Controls.Properties.Resources.first;
this.panel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel3.Location = new System.Drawing.Point(6, 6);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(68, 46);
this.panel3.TabIndex = 2;
this.panel3.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseDown);
//
// panel2
//
this.panel2.BackgroundImage = global::HZH_Controls.Properties.Resources.right;
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel2.Location = new System.Drawing.Point(154, 6);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(68, 46);
this.panel2.TabIndex = 1;
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel2_MouseDown);
//
// panel1
//
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.left;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.panel1.Location = new System.Drawing.Point(80, 6);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(68, 46);
this.panel1.TabIndex = 0;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// UCPagerControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "UCPagerControl";
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The table layout panel1
/// </summary>
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
/// <summary>
/// The panel4
/// </summary>
private System.Windows.Forms.Panel panel4;
/// <summary>
/// The panel3
/// </summary>
private System.Windows.Forms.Panel panel3;
/// <summary>
/// The panel2
/// </summary>
private System.Windows.Forms.Panel panel2;
/// <summary>
/// The panel1
/// </summary>
private System.Windows.Forms.Panel panel1;
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="UCPagerControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControl.
/// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
[ToolboxItem(true)]
public partial class UCPagerControl : UCPagerControlBase
{
/// <summary>
/// Initializes a new instance of the <see cref="UCPagerControl" /> class.
/// </summary>
public UCPagerControl()
{
InitializeComponent();
}
/// <summary>
/// Handles the MouseDown event of the panel1 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 panel1_MouseDown(object sender, MouseEventArgs e)
{
PreviousPage();
}
/// <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;
}
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-09-2019
//
// ***********************************************************************
// <copyright file="UCPagerControl.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControl.
/// Implements the <see cref="HZH_Controls.Controls.UCPagerControlBase" />
/// </summary>
/// <seealso cref="HZH_Controls.Controls.UCPagerControlBase" />
[ToolboxItem(true)]
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>
/// Initializes a new instance of the <see cref="UCPagerControl" /> class.
/// </summary>
public UCPagerControl()
{
InitializeComponent();
}
/// <summary>
/// Handles the MouseDown event of the panel1 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 panel1_MouseDown(object sender, MouseEventArgs e)
{
PreviousPage();
}
/// <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"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<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>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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:sequence>
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<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>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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:sequence>
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -105,12 +105,48 @@ namespace HZH_Controls.Controls
set
{
base.PageSize = value;
ResetPageCount();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
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
if (PageIndex == 1)
return;
PageIndex = 1;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
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
return;
}
PageIndex--;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
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
return;
}
PageIndex++;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
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
if (PageIndex == PageCount)
return;
PageIndex = PageCount;
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
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
PageIndex = (sender as UCBtnExt).BtnText.ToInt();
StartIndex = (PageIndex - 1) * PageSize;
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
PageIndex = txtPage.InputText.ToInt();
StartIndex = (PageIndex - 1) * PageSize;
ReloadPage();
var s = GetCurrentSource();
if (ShowSourceChanged != null)
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
ShowSourceChanged(s);
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
}
......
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="UCPagerControlBase.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControlBase.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// Implements the <see cref="HZH_Controls.Controls.IPageControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
/// <seealso cref="HZH_Controls.Controls.IPageControl" />
[ToolboxItem(false)]
public class UCPagerControlBase : UserControl, IPageControl
{
#region 构造
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UCPagerControlBase
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "UCPagerControlBase";
this.Size = new System.Drawing.Size(304, 58);
this.Load += new System.EventHandler(this.UCPagerControlBase_Load);
this.ResumeLayout(false);
}
#endregion
#endregion
/// <summary>
/// 总页数
/// </summary>
/// <value>The page count.</value>
public virtual int PageCount
{
get;
set;
}
/// <summary>
/// The m page index
/// </summary>
private int m_pageIndex = 1;
/// <summary>
/// 当前页码
/// </summary>
/// <value>The index of the page.</value>
public virtual int PageIndex
{
get { return m_pageIndex; }
set { m_pageIndex = value; }
}
private List<object> dataSource;
/// <summary>
/// 关联的数据源
/// </summary>
/// <value>The data source.</value>
public virtual List<object> DataSource
{
get { return dataSource; }
set
{
dataSource = value;
}
}
/// <summary>
/// 数据源改变时发生
/// </summary>
public virtual event PageControlEventHandler ShowSourceChanged;
/// <summary>
/// The m page size
/// </summary>
private int m_pageSize = 1;
/// <summary>
/// 每页显示数量
/// </summary>
/// <value>The size of the page.</value>
[Description("每页显示数量"), Category("自定义")]
public virtual int PageSize
{
get { return m_pageSize; }
set { m_pageSize = value; }
}
/// <summary>
/// The start index
/// </summary>
private int startIndex = 0;
/// <summary>
/// 开始的下标
/// </summary>
/// <value>The start index.</value>
[Description("开始的下标"), Category("自定义")]
public virtual int StartIndex
{
get { return startIndex; }
set
{
startIndex = value;
if (startIndex <= 0)
startIndex = 0;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="UCPagerControlBase" /> class.
/// </summary>
public UCPagerControlBase()
{
InitializeComponent();
}
/// <summary>
/// Handles the Load event of the UCPagerControlBase 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 UCPagerControlBase_Load(object sender, EventArgs e)
{
if (DataSource == null)
ShowBtn(false, false);
else
{
ShowBtn(false, DataSource.Count > PageSize);
}
}
/// <summary>
/// 第一页
/// </summary>
public virtual void FirstPage()
{
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 上一页
/// </summary>
public virtual void PreviousPage()
{
if (startIndex == 0)
return;
startIndex -= m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 下一页
/// </summary>
public virtual void NextPage()
{
if (startIndex + m_pageSize >= DataSource.Count)
{
return;
}
startIndex += m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 最后一页
/// </summary>
public virtual void EndPage()
{
if (DataSource == null)
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(null);
}
return;
}
startIndex = DataSource.Count - m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 刷新数据
/// </summary>
public virtual void Reload()
{
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns>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)
{ }
}
}
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 08-08-2019
//
// ***********************************************************************
// <copyright file="UCPagerControlBase.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HZH_Controls.Controls
{
/// <summary>
/// Class UCPagerControlBase.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// Implements the <see cref="HZH_Controls.Controls.IPageControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
/// <seealso cref="HZH_Controls.Controls.IPageControl" />
[ToolboxItem(false)]
public class UCPagerControlBase : UserControl, IPageControl
{
#region 构造
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UCPagerControlBase
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Name = "UCPagerControlBase";
this.Size = new System.Drawing.Size(304, 58);
this.Load += new System.EventHandler(this.UCPagerControlBase_Load);
this.ResumeLayout(false);
}
#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>
/// <value>The page count.</value>
public virtual int PageCount
{
get;
set;
}
/// <summary>
/// The m page index
/// </summary>
private int m_pageIndex = 1;
/// <summary>
/// 当前页码
/// </summary>
/// <value>The index of the page.</value>
public virtual int PageIndex
{
get { return m_pageIndex; }
set { m_pageIndex = value; }
}
private List<object> dataSource;
/// <summary>
/// 关联的数据源
/// </summary>
/// <value>The data source.</value>
public virtual List<object> DataSource
{
get { return dataSource; }
set
{
dataSource = value;
}
}
/// <summary>
/// 数据源改变时发生
/// </summary>
public virtual event PageControlEventHandler ShowSourceChanged;
/// <summary>
/// The m page size
/// </summary>
private int m_pageSize = 10;
/// <summary>
/// 每页显示数量
/// </summary>
/// <value>The size of the page.</value>
[Description("每页显示数量"), Category("自定义")]
public virtual int PageSize
{
get { return m_pageSize; }
set { m_pageSize = value; }
}
/// <summary>
/// The start index
/// </summary>
private int startIndex = 0;
/// <summary>
/// 开始的下标
/// </summary>
/// <value>The start index.</value>
[Description("开始的下标"), Category("自定义")]
public virtual int StartIndex
{
get { return startIndex; }
set
{
startIndex = value;
if (startIndex <= 0)
startIndex = 0;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="UCPagerControlBase" /> class.
/// </summary>
public UCPagerControlBase()
{
InitializeComponent();
}
/// <summary>
/// Handles the Load event of the UCPagerControlBase 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 UCPagerControlBase_Load(object sender, EventArgs e)
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (DataSource == null)
ShowBtn(false, false);
else
{
ShowBtn(false, DataSource.Count > PageSize);
}
}
else
{
if (PageCount <= 1)
{
ShowBtn(false, false);
}
else
{
ShowBtn(false, PageCount > 1);
}
}
}
/// <summary>
/// 第一页
/// </summary>
public virtual void FirstPage()
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
startIndex = 0;
PageIndex = 1;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary>
/// 上一页
/// </summary>
public virtual void PreviousPage()
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (startIndex == 0)
return;
startIndex -= m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (PageIndex <= 1)
return;
PageIndex--;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary>
/// 下一页
/// </summary>
public virtual void NextPage()
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (startIndex + m_pageSize >= DataSource.Count)
{
return;
}
startIndex += m_pageSize;
if (startIndex < 0)
startIndex = 0;
var s = GetCurrentSource();
if (ShowSourceChanged != null)
{
ShowSourceChanged(s);
}
}
else
{
if (PageIndex >= PageCount)
return;
PageIndex++;
SetShow();
if (ShowSourceChanged != null)
{
ShowSourceChanged(this);
}
}
}
/// <summary>
/// 最后一页
/// </summary>
public virtual void EndPage()
{
if (PageModel == HZH_Controls.Controls.PageModel.Soure)
{
if (DataSource == null)
{
if (ShowSourceChanged != null)
{
ShowSourceChanged(null);
}
return;
}
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 @@
//
// dgvRight
//
this.dgvRight.AutoRowsScroll = true;
this.dgvRight.BackColor = System.Drawing.Color.White;
this.dgvRight.Columns = null;
this.dgvRight.DataSource = null;
......@@ -100,12 +100,11 @@
this.dgvRight.HeadHeight = 40;
this.dgvRight.HeadPadingLeft = 0;
this.dgvRight.HeadTextColor = System.Drawing.Color.Black;
this.dgvRight.IsCloseAutoHeight = false;
this.dgvRight.IsShowCheckBox = true;
this.dgvRight.IsShowHead = true;
this.dgvRight.Location = new System.Drawing.Point(1, 1);
this.dgvRight.Name = "dgvRight";
this.dgvRight.Page = null;
this.dgvRight.Name = "dgvRight";
this.dgvRight.RowHeight = 40;
this.dgvRight.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.dgvRight.Size = new System.Drawing.Size(194, 395);
......@@ -196,7 +195,6 @@
//
// dgvLeft
//
this.dgvLeft.AutoRowsScroll = true;
this.dgvLeft.BackColor = System.Drawing.Color.White;
this.dgvLeft.Columns = null;
this.dgvLeft.DataSource = null;
......@@ -205,12 +203,10 @@
this.dgvLeft.HeadHeight = 40;
this.dgvLeft.HeadPadingLeft = 0;
this.dgvLeft.HeadTextColor = System.Drawing.Color.Black;
this.dgvLeft.IsCloseAutoHeight = false;
this.dgvLeft.IsShowCheckBox = true;
this.dgvLeft.IsShowHead = true;
this.dgvLeft.Location = new System.Drawing.Point(1, 1);
this.dgvLeft.Name = "dgvLeft";
this.dgvLeft.Page = null;
this.dgvLeft.RowHeight = 40;
this.dgvLeft.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.dgvLeft.Size = new System.Drawing.Size(193, 395);
......
......@@ -122,8 +122,6 @@ namespace HZH_Controls.Controls
public UCTransfer()
{
InitializeComponent();
dgvLeft.IsCloseAutoHeight = true;
dgvRight.IsCloseAutoHeight = true;
LeftColumns = new DataGridViewColumnEntity[0];
RightColumns = new DataGridViewColumnEntity[0];
LeftDataSource = new object[0];
......
......@@ -106,6 +106,7 @@ namespace HZH_Controls.Forms
this.ShowInTaskbar = false;
this.Text = "FrmWithTitle";
this.Shown += new System.EventHandler(this.FrmWithTitle_Shown);
this.SizeChanged += new System.EventHandler(this.FrmWithTitle_SizeChanged);
this.VisibleChanged += new System.EventHandler(this.FrmWithTitle_VisibleChanged);
this.ResumeLayout(false);
......
......@@ -113,5 +113,10 @@ namespace HZH_Controls.Forms
{
this.Close();
}
private void FrmWithTitle_SizeChanged(object sender, EventArgs e)
{
btnClose.Location = new Point(this.Width - btnClose.Width, btnClose.Location.Y);
}
}
}
......@@ -67,6 +67,7 @@
<Compile Include="Controls\Charts\RadarChart\UCRadarChart.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\DataGridView\IDataGridViewCustomCell.cs" />
<Compile Include="Controls\GraphicalOverlay\GraphicalOverlayComponent.cs">
<SubType>Component</SubType>
</Compile>
......@@ -96,6 +97,7 @@
</Compile>
<Compile Include="Controls\Navigation\CrumbNavigationClickEventArgs.cs" />
<Compile Include="Controls\Navigation\CrumbNavigationItem.cs" />
<Compile Include="Controls\Page\PageModel.cs" />
<Compile Include="Controls\Panel\UCPanelQuote.cs">
<SubType>Component</SubType>
</Compile>
......@@ -258,8 +260,8 @@
<DependentUpon>UCLEDTime.cs</DependentUpon>
</Compile>
<Compile Include="Controls\List\IListViewItem.cs" />
<Compile Include="Controls\List\IPageControl.cs" />
<Compile Include="Controls\List\PageControlEventHandler.cs" />
<Compile Include="Controls\Page\IPageControl.cs" />
<Compile Include="Controls\Page\PageControlEventHandler.cs" />
<Compile Include="Controls\List\UCListView.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -272,16 +274,16 @@
<Compile Include="Controls\List\UCListViewItem.Designer.cs">
<DependentUpon>UCListViewItem.cs</DependentUpon>
</Compile>
<Compile Include="Controls\List\UCPagerControl.cs">
<Compile Include="Controls\Page\UCPagerControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\List\UCPagerControl.Designer.cs">
<Compile Include="Controls\Page\UCPagerControl.Designer.cs">
<DependentUpon>UCPagerControl.cs</DependentUpon>
</Compile>
<Compile Include="Controls\List\UCPagerControl2.cs">
<Compile Include="Controls\Page\UCPagerControl2.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\List\UCPagerControl2.Designer.cs">
<Compile Include="Controls\Page\UCPagerControl2.Designer.cs">
<DependentUpon>UCPagerControl2.cs</DependentUpon>
</Compile>
<Compile Include="Controls\Menu\IMenuItem.cs" />
......@@ -482,7 +484,7 @@
<Compile Include="Controls\List\UCListItemExt.Designer.cs">
<DependentUpon>UCListItemExt.cs</DependentUpon>
</Compile>
<Compile Include="Controls\List\UCPagerControlBase.cs">
<Compile Include="Controls\Page\UCPagerControlBase.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\Process\UCProcessExt.cs">
......@@ -705,13 +707,13 @@
<EmbeddedResource Include="Controls\List\UCListViewItem.resx">
<DependentUpon>UCListViewItem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControl.resx">
<EmbeddedResource Include="Controls\Page\UCPagerControl.resx">
<DependentUpon>UCPagerControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControl2.resx">
<EmbeddedResource Include="Controls\Page\UCPagerControl2.resx">
<DependentUpon>UCPagerControl2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\List\UCPagerControlBase.resx">
<EmbeddedResource Include="Controls\Page\UCPagerControlBase.resx">
<DependentUpon>UCPagerControlBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\Menu\UCMenu.resx">
......
......@@ -48,6 +48,7 @@ namespace Test
tnControl.Nodes.Add("横向列表");
tnControl.Nodes.Add("分页控件");
tnControl.Nodes.Add("表格");
tnControl.Nodes.Add("表格-自定义单元格");
tnControl.Nodes.Add("树表格");
tnControl.Nodes.Add("进度条");
tnControl.Nodes.Add("步骤控件");
......@@ -220,6 +221,9 @@ namespace Test
case "表格":
AddControl(new UC.UCTestGridTable());
break;
case "表格-自定义单元格":
AddControl(new UC.UCTestGridTableCustom());
break;
case "树表格":
AddControl(new UC.UCTestTreeGridTable());
break;
......@@ -275,7 +279,7 @@ namespace Test
AddControl(new UC.UCTestNavigationMenuExt());
break;
case "类Office导航菜单":
AddControl(new UC.UCTestNavigationMenuOffice());
AddControl(new UC.UCTestNavigationMenuOffice());
break;
case "分割线标签":
AddControl(new UC.UCTestSplitLabel());
......@@ -294,7 +298,7 @@ namespace Test
#region 图表 English:Chart
case "组织结构图":
AddControl(new UC.UCTestMindMapping() { Dock = DockStyle.Fill });
break;
break;
case "滚动图表":
AddControl(new UC.UCTestWaveChart() { Dock = DockStyle.Fill });
break;
......@@ -305,8 +309,8 @@ namespace Test
AddControl(new UC.UCTestFunnelChart());
break;
case "Live Charts":
AddControl(new UC.UCTestLiveCharts());
break;
AddControl(new UC.UCTestLiveCharts());
break;
#endregion
#region 工业 English:Industry
......
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将丢失。
// 重新生成代码,这些更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Test.Properties
{
namespace Test.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
......@@ -22,50 +22,52 @@ namespace Test.Properties
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
/// 方法是使用此强类型资源类
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap rowicon {
get {
object obj = ResourceManager.GetObject("rowicon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}
......@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
......@@ -60,6 +60,7 @@
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
......@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
......@@ -85,9 +87,10 @@
<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:sequence>
<xsd:attribute name="name" type="xsd:string" 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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
......@@ -109,9 +112,13 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.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 name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="rowicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\rowicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
\ No newline at end of file
......@@ -145,6 +145,24 @@
<Compile Include="UC\UCTestGraphicalOverlay.Designer.cs">
<DependentUpon>UCTestGraphicalOverlay.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestGridTableCustom.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestGridTableCustom.Designer.cs">
<DependentUpon>UCTestGridTableCustom.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestGridTable_CustomCell.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestGridTable_CustomCell.Designer.cs">
<DependentUpon>UCTestGridTable_CustomCell.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestGridTable_CustomCellIcon.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestGridTable_CustomCellIcon.Designer.cs">
<DependentUpon>UCTestGridTable_CustomCellIcon.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestIcon.cs">
<SubType>UserControl</SubType>
</Compile>
......@@ -642,6 +660,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="UC\UCTestArrow.resx">
<DependentUpon>UCTestArrow.cs</DependentUpon>
......@@ -673,6 +692,15 @@
<EmbeddedResource Include="UC\UCTestGridTable.resx">
<DependentUpon>UCTestGridTable.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestGridTableCustom.resx">
<DependentUpon>UCTestGridTableCustom.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestGridTable_CustomCell.resx">
<DependentUpon>UCTestGridTable_CustomCell.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestGridTable_CustomCellIcon.resx">
<DependentUpon>UCTestGridTable_CustomCellIcon.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestHorizontalList.resx">
<DependentUpon>UCTestHorizontalList.cs</DependentUpon>
</EmbeddedResource>
......@@ -920,6 +948,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="log.ico" />
<None Include="Resources\rowicon.png" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\fingerprint.png" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\user.png" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\view.png" />
......
......@@ -33,7 +33,6 @@
//
// ucDataGridView1
//
this.ucDataGridView1.AutoRowsScroll = false;
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
......@@ -42,12 +41,10 @@
this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 0;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(739, 599);
......
......@@ -16,18 +16,8 @@ namespace Test.UC
public UCTestGridTable()
{
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)
{
......@@ -51,12 +41,8 @@ namespace Test.UC
Sex = i % 2
};
lstSource.Add(model);
}
var page = new UCPagerControl2();
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
}
this.ucDataGridView1.DataSource = lstSource;
}
}
......
namespace Test.UC
{
partial class UCTestGridTableCustom
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView();
this.SuspendLayout();
//
// ucDataGridView1
//
this.ucDataGridView1.AutoScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
this.ucDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucDataGridView1.HeadFont = new System.Drawing.Font("微软雅黑", 12F);
this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 0;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(831, 609);
this.ucDataGridView1.TabIndex = 5;
//
// UCTestGridTableCustom
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.ucDataGridView1);
this.Name = "UCTestGridTableCustom";
this.Size = new System.Drawing.Size(831, 609);
this.Load += new System.EventHandler(this.UCTestGridTableCustom_Load);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCDataGridView ucDataGridView1;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HZH_Controls.Controls;
namespace Test.UC
{
public partial class UCTestGridTableCustom : UserControl
{
public UCTestGridTableCustom()
{
InitializeComponent();
}
private void UCTestGridTableCustom_Load(object sender, EventArgs e)
{
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { Width = 35, WidthType = SizeType.Absolute, CustomCellType = typeof(UCTestGridTable_CustomCellIcon) });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 50, WidthType = SizeType.Percent });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 50, WidthType = SizeType.Percent });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = 50, WidthType = SizeType.Percent, Format = (a) => { return ((int)a) == 0 ? "女" : "男"; } });
lstCulumns.Add(new DataGridViewColumnEntity() { Width = 155, WidthType = SizeType.Absolute,CustomCellType=typeof(UCTestGridTable_CustomCell) });
this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true;
List<object> lstSource = new List<object>();
for (int i = 0; i < 50; i++)
{
TestGridModel model = new TestGridModel()
{
ID = i.ToString(),
Age = 3 * i,
Name = "姓名——" + i,
Birthday = DateTime.Now.AddYears(-10),
Sex = i % 2
};
lstSource.Add(model);
}
this.ucDataGridView1.DataSource = lstSource;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<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>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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:sequence>
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
namespace Test.UC
{
partial class UCTestGridTable_CustomCell
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ucBtnExt1 = new HZH_Controls.Controls.UCBtnExt();
this.ucBtnExt2 = new HZH_Controls.Controls.UCBtnExt();
this.SuspendLayout();
//
// ucBtnExt1
//
this.ucBtnExt1.BackColor = System.Drawing.Color.Transparent;
this.ucBtnExt1.BtnBackColor = System.Drawing.Color.White;
this.ucBtnExt1.BtnFont = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ucBtnExt1.BtnForeColor = System.Drawing.Color.White;
this.ucBtnExt1.BtnText = "修改";
this.ucBtnExt1.ConerRadius = 5;
this.ucBtnExt1.Cursor = System.Windows.Forms.Cursors.Hand;
this.ucBtnExt1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBtnExt1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBtnExt1.IsRadius = true;
this.ucBtnExt1.IsShowRect = true;
this.ucBtnExt1.IsShowTips = false;
this.ucBtnExt1.Location = new System.Drawing.Point(16, 4);
this.ucBtnExt1.Margin = new System.Windows.Forms.Padding(0);
this.ucBtnExt1.Name = "ucBtnExt1";
this.ucBtnExt1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(58)))));
this.ucBtnExt1.RectWidth = 1;
this.ucBtnExt1.Size = new System.Drawing.Size(57, 25);
this.ucBtnExt1.TabIndex = 0;
this.ucBtnExt1.TabStop = false;
this.ucBtnExt1.TipsColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(30)))), ((int)(((byte)(99)))));
this.ucBtnExt1.TipsText = "";
this.ucBtnExt1.BtnClick += new System.EventHandler(this.ucBtnExt1_BtnClick);
//
// ucBtnExt2
//
this.ucBtnExt2.BackColor = System.Drawing.Color.Transparent;
this.ucBtnExt2.BtnBackColor = System.Drawing.Color.White;
this.ucBtnExt2.BtnFont = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.ucBtnExt2.BtnForeColor = System.Drawing.Color.White;
this.ucBtnExt2.BtnText = "删除";
this.ucBtnExt2.ConerRadius = 5;
this.ucBtnExt2.Cursor = System.Windows.Forms.Cursors.Hand;
this.ucBtnExt2.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucBtnExt2.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
this.ucBtnExt2.IsRadius = true;
this.ucBtnExt2.IsShowRect = true;
this.ucBtnExt2.IsShowTips = false;
this.ucBtnExt2.Location = new System.Drawing.Point(82, 4);
this.ucBtnExt2.Margin = new System.Windows.Forms.Padding(0);
this.ucBtnExt2.Name = "ucBtnExt2";
this.ucBtnExt2.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(58)))));
this.ucBtnExt2.RectWidth = 1;
this.ucBtnExt2.Size = new System.Drawing.Size(57, 25);
this.ucBtnExt2.TabIndex = 0;
this.ucBtnExt2.TabStop = false;
this.ucBtnExt2.TipsColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(30)))), ((int)(((byte)(99)))));
this.ucBtnExt2.TipsText = "";
this.ucBtnExt2.BtnClick += new System.EventHandler(this.ucBtnExt2_BtnClick);
//
// UCTestGridTable_CustomCell
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.ucBtnExt2);
this.Controls.Add(this.ucBtnExt1);
this.Name = "UCTestGridTable_CustomCell";
this.Size = new System.Drawing.Size(155, 35);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCBtnExt ucBtnExt1;
private HZH_Controls.Controls.UCBtnExt ucBtnExt2;
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test.UC
{
public partial class UCTestGridTable_CustomCell : UserControl, HZH_Controls.Controls.IDataGridViewCustomCell
{
private TestGridModel m_object = null;
public UCTestGridTable_CustomCell()
{
InitializeComponent();
}
public void SetBindSource(object obj)
{
if (obj is TestGridModel)
m_object = (TestGridModel)obj;
}
private void ucBtnExt1_BtnClick(object sender, EventArgs e)
{
if (m_object != null)
{
HZH_Controls.Forms.FrmTips.ShowTipsSuccess(this.FindForm(),"修改:"+m_object.Name);
}
}
private void ucBtnExt2_BtnClick(object sender, EventArgs e)
{
if (m_object != null)
{
HZH_Controls.Forms.FrmTips.ShowTipsSuccess(this.FindForm(), "删除:" + m_object.Name);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<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>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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:sequence>
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
namespace Test.UC
{
partial class UCTestGridTable_CustomCellIcon
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UCTestGridTable_CustomCellIcon
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.Name = "UCTestGridTable_CustomCellIcon";
this.Size = new System.Drawing.Size(28, 28);
this.ResumeLayout(false);
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Test.UC
{
public partial class UCTestGridTable_CustomCellIcon : UserControl, HZH_Controls.Controls.IDataGridViewCustomCell
{
public UCTestGridTable_CustomCellIcon()
{
InitializeComponent();
}
public void SetBindSource(object obj)
{
if (obj is TestGridModel)
{
this.BackgroundImage = Properties.Resources.rowicon;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<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>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<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:sequence>
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -32,16 +32,23 @@
this.ucPagerControl21 = new HZH_Controls.Controls.UCPagerControl2();
this.ucPagerControl1 = new HZH_Controls.Controls.UCPagerControl();
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();
//
// ucPagerControl21
//
this.ucPagerControl21.BackColor = System.Drawing.Color.White;
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.PageCount = 0;
this.ucPagerControl21.PageIndex = 1;
this.ucPagerControl21.PageModel = HZH_Controls.Controls.PageModel.Soure;
this.ucPagerControl21.PageSize = 0;
this.ucPagerControl21.Size = new System.Drawing.Size(709, 41);
this.ucPagerControl21.StartIndex = 0;
......@@ -50,10 +57,11 @@
// ucPagerControl1
//
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.PageCount = 0;
this.ucPagerControl1.PageIndex = 1;
this.ucPagerControl1.PageModel = HZH_Controls.Controls.PageModel.Soure;
this.ucPagerControl1.PageSize = 1;
this.ucPagerControl1.Size = new System.Drawing.Size(304, 58);
this.ucPagerControl1.StartIndex = 0;
......@@ -62,24 +70,75 @@
// label1
//
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.Size = new System.Drawing.Size(197, 12);
this.label1.TabIndex = 7;
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
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.label1);
this.Controls.Add(this.ucPagerControl1);
this.Controls.Add(this.ucPagerControl21);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
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.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
......@@ -88,5 +147,9 @@
private HZH_Controls.Controls.UCPagerControl2 ucPagerControl21;
private HZH_Controls.Controls.UCPagerControl ucPagerControl1;
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
ucPagerControl1.DataSource = lstPage2;
this.ucPagerControl1.FirstPage();
ucPagerControl22.PageCount = 10;
ucPagerControl22.PageIndex = 1;
ucPagerControl2.PageCount = 10;
ucPagerControl2.PageIndex = 1;
}
}
}
......@@ -126,4 +126,13 @@
ZW1zBV9zaXplCF92ZXJzaW9uBQAACAgCAAAACQMAAAAAAAAAAAAAABADAAAAAAAAAAs=
</value>
</data>
<data name="ucPagerControl22.DataSource" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLk9iamVjdAMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBQAACAgCAAAACQMAAAAAAAAAAAAAABADAAAAAAAAAAs=
</value>
</data>
</root>
\ No newline at end of file
......@@ -33,7 +33,6 @@
//
// ucDataGridView1
//
this.ucDataGridView1.AutoRowsScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
......@@ -42,12 +41,10 @@
this.ucDataGridView1.HeadHeight = 40;
this.ucDataGridView1.HeadPadingLeft = 24;
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
this.ucDataGridView1.IsCloseAutoHeight = false;
this.ucDataGridView1.IsShowCheckBox = false;
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Page = null;
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(825, 674);
......
......@@ -15,19 +15,9 @@ namespace Test.UC
{
public UCTestTreeGridTable()
{
InitializeComponent();
ucDataGridView1.SizeChanged += ucDataGridView1_SizeChanged;
InitializeComponent();
}
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)
{
......@@ -55,10 +45,7 @@ namespace Test.UC
AddChilds(model, 5);
}
var page = new UCPagerControl2();
page.DataSource = lstSource;
this.ucDataGridView1.Page = page;
this.ucDataGridView1.First();
this.ucDataGridView1.DataSource = lstSource;
}
private void AddChilds(TestGridModel tm, int intCount)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!