Commit 57a8ef89 kwwwvagaa

优化表格标题显示

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