Commit 57a8ef89 kwwwvagaa

优化表格标题显示

1 个父辈 d4225c39
......@@ -51,8 +51,8 @@ namespace HZH_Controls.Controls
this.panHead = new System.Windows.Forms.Panel();
this.panColumns = new System.Windows.Forms.TableLayoutPanel();
this.panHeadLeft = new System.Windows.Forms.Panel();
this.panRow = new System.Windows.Forms.FlowLayoutPanel();
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
this.panRow = new System.Windows.Forms.Panel();
this.panHead.SuspendLayout();
this.SuspendLayout();
//
......@@ -87,6 +87,16 @@ namespace HZH_Controls.Controls
this.panHeadLeft.Size = new System.Drawing.Size(0, 39);
this.panHeadLeft.TabIndex = 2;
//
// panRow
//
this.panRow.AutoScroll = true;
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(317, 225);
this.panRow.TabIndex = 1;
this.panRow.Scroll += new System.Windows.Forms.ScrollEventHandler(this.panRow_Scroll);
//
// ucSplitLine_H1
//
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
......@@ -97,24 +107,17 @@ namespace HZH_Controls.Controls
this.ucSplitLine_H1.TabIndex = 0;
this.ucSplitLine_H1.TabStop = false;
//
// panRow
//
this.panRow.Location = new System.Drawing.Point(0, 40);
this.panRow.Name = "panRow";
this.panRow.Size = new System.Drawing.Size(1061, 525);
this.panRow.TabIndex = 1;
//
// UCDataGridView
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.panHead);
this.Controls.Add(this.panRow);
this.Controls.Add(this.panHead);
this.Name = "UCDataGridView";
this.Size = new System.Drawing.Size(1061, 565);
this.Padding = new System.Windows.Forms.Padding(0, 40, 0, 0);
this.Size = new System.Drawing.Size(317, 265);
this.Scroll += new System.Windows.Forms.ScrollEventHandler(this.UCDataGridView_Scroll);
this.SizeChanged += new System.EventHandler(this.UCDataGridView_SizeChanged);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.UCDataGridView_Paint);
this.panHead.ResumeLayout(false);
this.ResumeLayout(false);
......@@ -135,13 +138,10 @@ namespace HZH_Controls.Controls
/// </summary>
private UCSplitLine_H ucSplitLine_H1;
/// <summary>
/// The pan row
/// </summary>
private System.Windows.Forms.Panel panRow;
/// <summary>
/// The pan head left
/// </summary>
private System.Windows.Forms.Panel panHeadLeft;
private System.Windows.Forms.FlowLayoutPanel panRow;
}
}
......@@ -348,7 +348,21 @@ namespace HZH_Controls.Controls
}
return null;
}
[Bindable(false)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool AutoScroll
{
get
{
return base.AutoScroll;
}
set
{
base.AutoScroll = value;
}
}
#region 事件
/// <summary>
/// The head CheckBox change event
......@@ -380,6 +394,7 @@ namespace HZH_Controls.Controls
#endregion
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="UCDataGridView" /> class.
/// </summary>
......@@ -428,19 +443,19 @@ namespace HZH_Controls.Controls
_width += 30;
if (_width > this.Width)
{
this.panRow.Width = _width;
//this.panRow.Width = _width;
this.panHead.Width = _width;
}
else
{
if (m_columns.Any(p => p.WidthType == SizeType.AutoSize))
{
this.panRow.Width = this.Width;
//this.panRow.Width = this.Width;
this.panHead.Width = this.Width;
}
else
{
this.panRow.Width = _width;
//this.panRow.Width = _width;
this.panHead.Width = _width;
}
}
......@@ -560,6 +575,7 @@ namespace HZH_Controls.Controls
if (row.RowHeight != m_rowHeight)
row.RowHeight = m_rowHeight;
item.Visible = true;
item.Width = panHead.Width;
item.BringToFront();
Rows.Add(row);
......@@ -588,6 +604,7 @@ namespace HZH_Controls.Controls
row.BindingCellData();
Control rowControl = (row as Control);
rowControl.Width = panHead.Width;
row.RowHeight = m_rowHeight;
rowControl.Dock = DockStyle.Top;
row.CellClick += (a, b) => { SetSelectRow(rowControl, b); };
......@@ -602,7 +619,7 @@ namespace HZH_Controls.Controls
}
}
this.panRow.Height = intSourceCount * RowHeight;
//this.panRow.Height = intSourceCount * RowHeight;
}
else
{
......@@ -772,15 +789,20 @@ namespace HZH_Controls.Controls
private void UCDataGridView_Scroll(object sender, ScrollEventArgs e)
{
if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
panHead.Location = new Point(0, this.VerticalScroll.Value + this.panRow.Location.Y - panHead.Height - 2);
}
//if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
//{
// panHead.Location = new Point(0, this.VerticalScroll.Value + this.panRow.Location.Y - panHead.Height - 2);
//}
}
private void UCDataGridView_Paint(object sender, PaintEventArgs e)
private void panRow_Scroll(object sender, ScrollEventArgs e)
{
if (e.ScrollOrientation == ScrollOrientation.HorizontalScroll && this.panRow.Controls.Count>0)
{
Console.WriteLine(this.panRow.HorizontalScroll.Value);
Console.WriteLine(this.panRow.Controls[0].Location.X);
panHead.Location = new Point(this.panRow.HorizontalScroll.Value*-1 , 0);
}
}
}
}
......@@ -2,7 +2,7 @@
<package >
<metadata>
<id>$id$</id>
<version>1.0.11</version>
<version>1.0.12</version>
<title>HZHControls</title>
<authors>HuangZhengHui</authors>
<owners>HuangZhengHui</owners>
......
......@@ -33,7 +33,6 @@
//
// ucDataGridView1
//
this.ucDataGridView1.AutoScroll = true;
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
this.ucDataGridView1.Columns = null;
this.ucDataGridView1.DataSource = null;
......@@ -46,9 +45,10 @@
this.ucDataGridView1.IsShowHead = true;
this.ucDataGridView1.Location = new System.Drawing.Point(0, 0);
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.Padding = new System.Windows.Forms.Padding(0, 40, 0, 0);
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(739, 599);
this.ucDataGridView1.Size = new System.Drawing.Size(724, 510);
this.ucDataGridView1.TabIndex = 4;
//
// UCTestGridTable
......@@ -57,7 +57,7 @@
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.ucDataGridView1);
this.Name = "UCTestGridTable";
this.Size = new System.Drawing.Size(739, 599);
this.Size = new System.Drawing.Size(724, 510);
this.Load += new System.EventHandler(this.UCTestGridTable_Load);
this.ResumeLayout(false);
......
......@@ -23,9 +23,9 @@ namespace Test.UC
{
List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "ID", HeadText = "编号", Width = 70, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 100, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Name", HeadText = "姓名", Width = 500, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Age", HeadText = "年龄", Width = 500, WidthType = SizeType.Absolute });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 150, WidthType = SizeType.Absolute, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Birthday", HeadText = "生日", Width = 500, WidthType = SizeType.Absolute, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd"); } });
lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "Sex", HeadText = "性别", Width = 50, WidthType = SizeType.Absolute, Format = (a) => { return ((int)a) == 0 ? "女" : "男"; } });
this.ucDataGridView1.Columns = lstCulumns;
this.ucDataGridView1.IsShowCheckBox = true;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!