引用的控件需要更改 没有提供属性修改的设置时,可以通过重绘事件来更改UI
如:tableLayout 没有border,可以通过重绘来画出边框。tableLayout 重绘事件:
// 事件注册
this.tableLayoutPanel1.CellPaint += new TableLayoutCellPaintEventHandler(this.tableLayoutPanel1_CellPaint);
// 事件
private void tableLayoutPanel1_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
{
// 单元格重绘
Pen pp = new Pen(Color.Black);
e.Graphics.DrawRectangle(pp, e.CellBounds.X, e.CellBounds.Y, e.CellBounds.X + e.CellBounds.Width - 1, e.CellBounds.Y + e.CellBounds.Height - 1);
}