How to change the font style?

Source: Internet
Author: User
Changing the font style is easier than changing the font size, because a font style can be passed as a parameter in the font constructor. For example: a bold label font:

Label Label =   New Label ();
...
Label. Font =   New Font (Label. Font, fontstyle. Bold );

If you want to keep the initial style and bold it:
Label. Font= NewFont (Label. Font, label. Font. Style|Fontstyle. Bold );

The above solution creates a new font object, no matter what you need! Here is a more convenient method: bold font. You can create a new font object only when necessary:
Static   Public Font boldfont (Font font)
{
If (Font ! =   Null )
{
Fontstyle = Font. style;
If (Fontstyle & Fontstyle. Bold) =   0 )
{
Fontstyle| =Fontstyle. Bold;
Font= NewFont (font, fontstyle );
}
}
Return Font;
}

For example, bold a label font: Label. Font=Boldfont (Label. font );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.