Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Label1.Text = "Normal Text"
Label1.Text &= "BOLD TEXT"
Label1.Text &= "Normal Text"


is there a way that make part of my string as bold in Label text like aabove I want the second line to be bold only

Output:

Normal Text
BOLD TEXT
Normal Text

I tried the below and it didn't work:

Label1.Text &= "< b>BOLD TEXT< /b>"
Posted
Updated 8-Jul-14 23:43pm
v4
Comments
CHill60 9-Jul-14 6:01am    
Is this WinForms or Web?

1 solution

It works for me :
just use b tag around the text.
C#
Label1.Text = "Normal Text"
Label1.Text &= "<b>BOLD TEXT</b>"
Label1.Text &= "Normal Text"


Hope it works for you too.
[Edit-1]
It is not allowing me to write b tag. it changes in bold text you can see 'BOLD TEXT'.
[Edit-2]
Now it's showing correctly. Thanks Rohan for your help.

Good luck.
 
Share this answer
 
v5
Comments
TheWebDeveloper 9-Jul-14 6:07am    
I already tried it and it didn't work as I stated in my question.
It keep displaying the tag with my text: BOLD TEXT
Raje_ 9-Jul-14 6:18am    
It seems you updated your question same time when i submitted my solution. any way Is it a win form or web app?
TheWebDeveloper 9-Jul-14 6:38am    
Windows App
Raje_ 9-Jul-14 6:51am    
You should have told it in your question.
Frankly speaking it is not possible in win form. you have some options to do it in other way.
here is the link :
Formatting text in WinForm Label

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900