SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles();
this.tableLayoutPanel2.SuspendLayout();
this.SuspendLayout();
tableLayoutPanel2.Controls.Clear();
tableLayoutPanel2.ColumnCount = value.ColumnCount;
tableLayoutPanel2.ColumnStyles.Clear();
for (int i = 0; i < this.tableLayoutPanel2.ColumnCount; i++) {
this.tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F/this.tableLayoutPanel2.ColumnCount));
}
this.tableLayoutPanel2.RowCount = value.ReservedCount / value.ColumnCount;
tableLayoutPanel2.RowStyles.Clear();
for (int i = 0; i < tableLayoutPanel2.RowCount; i++) {
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F/tableLayoutPanel2.RowCount));
}
// 动态添加控件
// 在这儿添加你的代码
...
tableLayoutPanel2.ResumeLayout(true);
this.ResumeLayout(true);protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}在自定义控件中添加的:
protected override CreateParams CreateParams
{
get
{
var parms = base.CreateParams;
parms.Style &= ~0x02000000; // Turn off WS_CLIPCHILDREN
return parms;
}
}本文出自勇哥的网站《少有人走的路》wwww.skcircle.com,转载请注明出处!讨论可扫码加群:



少有人走的路



















