Setting label text to bold

Status
Not open for further replies.

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

Can you show the needed coding that will apply Bold to the Text of a label?

I tried this but the syntax is wrong:

Code:
LabelStoreName.Typeface = Typeface.STYLE_BOLD

Thanks.
 
Try this ..

Code:
LabelStoreName.Typeface = Typeface.DEFAULT_BOLD

Cheers mj
 
Upvote 0
You can also set it in the designer:
SS-2013-02-22_11.19.28.png
 
Upvote 0
Hi Everyone,

Thanks for the replies.

The coding from mangojack worked. :D

Maybe .STYLE_BOLD should be removed from the Intelisence results because that's how I found it.

Erel,

Thanks for the helpful reply as well.
 
Upvote 0
Hi All,
I tried all of above suggestions but I can't made bold the label text. None of these codes working.

Where is my mistake? Can anyone helps me please.

Code:
    Dim MyFont As Typeface
    MyFont = Typeface.LoadFromAssets("arial_condensed_bold.ttf")

    Dim lblCustomer As Label
    lblCustomer.Initialize("")
    lblCustomer.Typeface=MyFont    
    lblCustomer.Typeface=Typeface.DEFAULT_BOLD
    lblCustomer.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lblCustomer.Text = CusName
    lblCustomer.TextSize=20
    lblCustomer.TextColor=Colors.RGB(6,14,172)

Code:
    Dim lblCustomer As Label
    lblCustomer.Initialize("")
    lblCustomer.Typeface=Typeface.CreateNew(Typeface.LoadFromAssets("arial_condensed_bold.ttf"),Typeface.STYLE_BOLD)
    lblCustomer.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lblCustomer.Text = CusName
    lblCustomer.TextSize=20
    lblCustomer.TextColor=Colors.RGB(6,14,172)
 
Upvote 0
What you've done looks correct to me. Maybe try moving the line where you set bold to the last line i.e. after setting it's text, size and color. Worth a shot?
 
Upvote 0
Thanks for your suggestion RandomCoder but problem isn't solved. I changed line to end but still didn't make bold.
 
Upvote 0
Does your code work if you use a standard font?
Of not then I think we may need to see more code.
 
Upvote 0
Hi Everyone,

Can you show the needed coding that will apply Bold to the Text of a label?

I tried this but the syntax is wrong:

Code:
LabelStoreName.Typeface = Typeface.STYLE_BOLD

Thanks.
This doesn't work because Style Bold returns integer unlike Typeface "Data Type".
 
Upvote 0
Status
Not open for further replies.
Back
Top