Commit b4132c6a kwwwvagaa

增加选项卡不可关闭功能

1 个父辈 09e1bd73
......@@ -64,6 +64,8 @@ namespace HZH_Controls.Controls
[Description("是否显示关闭按钮"), Category("自定义")]
public bool IsShowCloseBtn { get; set; }
[Description("不可关闭的标签序号列表,下标0"), Category("自定义")]
public int[] UncloseTabIndexs { get; set; }
/// <summary>
/// The back color
/// </summary>
......@@ -85,6 +87,15 @@ namespace HZH_Controls.Controls
}
}
private Color closeBtnColor = Color.FromArgb(255, 85, 51);
[Description("关闭按钮颜色")]
public Color CloseBtnColor
{
get { return closeBtnColor; }
set { closeBtnColor = value; }
}
/// <summary>
/// The border color
/// </summary>
......@@ -257,9 +268,14 @@ namespace HZH_Controls.Controls
this.PaintTabImage(e.Graphics, index);
if (IsShowCloseBtn)
{
if (UncloseTabIndexs != null)
{
if (UncloseTabIndexs.ToList().Contains(index))
return;
}
Rectangle rect = this.GetTabRect(index);
e.Graphics.DrawLine(new Pen(_borderColor, 1F), new Point(rect.Right - 15, rect.Top + 5), new Point(rect.Right - 5, rect.Top + 15));
e.Graphics.DrawLine(new Pen(_borderColor, 1F), new Point(rect.Right - 5, rect.Top + 5), new Point(rect.Right - 15, rect.Top + 15));
e.Graphics.DrawLine(new Pen(closeBtnColor, 1F), new Point(rect.Right - 15, rect.Top + 5), new Point(rect.Right - 5, rect.Top + 15));
e.Graphics.DrawLine(new Pen(closeBtnColor, 1F), new Point(rect.Right - 5, rect.Top + 5), new Point(rect.Right - 15, rect.Top + 15));
}
}
......@@ -489,6 +505,11 @@ namespace HZH_Controls.Controls
int index = GetMouseDownTabHead(mouseLocation);
if (index >= 0)
{
if (UncloseTabIndexs != null)
{
if (UncloseTabIndexs.ToList().Contains(index))
return;
}
Rectangle rect = this.GetTabRect(index);
var closeRect = new Rectangle(rect.Right - 15, rect.Top + 5, 10, 10);
if (closeRect.Contains(mouseLocation))
......
......@@ -64,6 +64,9 @@
this.tabControlExt1.Size = new System.Drawing.Size(573, 421);
this.tabControlExt1.SizeMode = System.Windows.Forms.TabSizeMode.FillToRight;
this.tabControlExt1.TabIndex = 1;
this.tabControlExt1.UncloseTabIndexs = new int[] {
0,
1};
//
// tabPage1
//
......
......@@ -29,6 +29,7 @@
private void InitializeComponent()
{
this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// ucDataGridView1
......@@ -37,7 +38,6 @@
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 = 24;
......@@ -48,23 +48,35 @@
this.ucDataGridView1.Name = "ucDataGridView1";
this.ucDataGridView1.RowHeight = 41;
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
this.ucDataGridView1.Size = new System.Drawing.Size(817, 674);
this.ucDataGridView1.Size = new System.Drawing.Size(807, 655);
this.ucDataGridView1.TabIndex = 5;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 677);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(515, 12);
this.label1.TabIndex = 6;
this.label1.Text = "*树表格第一列将作为展开缩进处理,请根据实际情况设置具体像素的宽度,请勿使用百分比宽度";
//
// UCTestTreeGridTable
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.label1);
this.Controls.Add(this.ucDataGridView1);
this.Name = "UCTestTreeGridTable";
this.Size = new System.Drawing.Size(817, 674);
this.Size = new System.Drawing.Size(817, 714);
this.Load += new System.EventHandler(this.UCTestTreeGridTable_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private HZH_Controls.Controls.UCDataGridView ucDataGridView1;
private System.Windows.Forms.Label label1;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!