[英]TableLayoutPanel cell border issue
您將需要owner.draw TLP:
這是一種方法:關閉CellBorder
並對此事件進行編碼
private void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
Rectangle r = e.CellBounds;
using (Pen pen = new Pen(Color.DarkGoldenrod))
{
// top and left lines
e.Graphics.DrawLine(pen, r.X, r.Y, r.X + r.Width, r.Y);
e.Graphics.DrawLine(pen, r.X, r.Y, r.X, r.Y + r.Height);
// last row? move hor.lines 1 up!
int cy = e.Row == tableLayoutPanel1.RowCount - 1 ? -1 : 0;
if (cy != 0) e.Graphics.DrawLine(pen, r.X, r.Y + r.Height + cy,
r.X + r.Width, r.Y + r.Height + cy);
// last column ? move vert. lines 1 left!
int cx = e.Column == tableLayoutPanel1.ColumnCount - 1 ? -1 : 0;
if (cx != 0) e.Graphics.DrawLine(pen, r.X + r.Width + cx, r.Y,
r.X + r.Width + cx, r.Y + r.Height);
}
}
但是您應該問自己,為什么會出現這種情況,以及用戶是否可能實際上看不到隱藏的列。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.