日期:2014-05-19  浏览次数:20914 次

请问winform里面的label可以用什么控件替代
在form里面   我要使用好多文字说名   但是label多了   每次重绘的时候   都好慢   而且刷屏的感觉   请问怎么解决?

------解决方案--------------------
例子倒是有,但是用尽量少的控件才是减少"慢"的感觉的方法,但是我的意思的代码如下:
public partial class LabelEx : Control
{
public LabelEx()
{
this.DoubleBuffered = true;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
if (this.DesignMode)
{
base.OnPaintBackground(e);
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
StringFormat format = new StringFormat();
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
e.Graphics.FillRectangle(SystemBrushes.Control, this.ClientRectangle);
e.Graphics.DrawString(this.Text, this.Font, SystemBrushes.ControlText, this.ClientRectangle, format);
}
}