Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apply Antialiasing to Labels in app?

Status
Not open for further replies.

cjtaylor

Programmer
Aug 12, 2001
69
US
Is there a simple way to provide antialiasing to all labels in an app or to the app as a whole? I can do it on individual labels by overriding the paint with the following. I was just wondering if there is a better way of doing this before writing a function to override all event handlers for the labels

private static void AntiAliasLabel(object sender, PaintEventArgs e)
{
Label lbl = (Label)sender;
Graphics g2 = e.Graphics;
Font fnt = lbl.Font;
g2.TextRenderingHint = TextRenderingHint.AntiAlias;

Thanks
g2.DrawString(lbl.Text, fnt, Brushes.Black, 0, 0);
}
 
Why don't you just create a class that extends the label and always applies the antialiasing on the draw?

public class AALabel : System.Windows.Forms.Label

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top