您需要owner.draw的TLP:
隱藏的第三列:
這是一個辦法:關閉和代碼此事件
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);
}
}
但你應該問問自己爲什麼情況已經出現,如果用戶不應該也許實際上看到有一列隱藏。
來源
2016-10-04 15:07:45
TaW