I came across this question and created my own simple Label control.
The .NET Label control is a surprisingly complex beast, so it is slower than we would like.
You can create a class that inherits Control, call SetStylein the constructor to make it double-buffered and colored by the user, then override the method OnPaintto call e.Graphics.DrawStringand draw the Textproperty.
Finally, override Textor TextChangedand call Invalidate.
Until you need AutoSize, it will be significantly faster than the standard Label control.
Here is my implementation: (Currently used in production)
class FastLabel : Control {
public FastLabel() {
SetStyle(ControlStyles.AllPaintingInWmPaint
| ControlStyles.CacheText
| ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw
| ControlStyles.UserPaint, true);
}
protected override void OnTextChanged(EventArgs e) { base.OnTextChanged(e); Invalidate(); }
protected override void OnFontChanged(EventArgs e) { base.OnFontChanged(e); Invalidate(); }
static readonly StringFormat format = new StringFormat {
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
protected override void OnPaint(PaintEventArgs e) {
e.Graphics.DrawString(Text, Font, SystemBrushes.ControlText, ClientRectangle, format);
}
}
, < <29 > .