How to set diffrent words in a label with diffrent fonts
-
Hello I'm using System.Windows.Forms.Label and I want to add some text, where one or more words are bold or italic. I tried it with html tags but does not work. Somewhere i did read it should be done by html tags. I did it like this: label1.Text="my <b>test</b> string"; In the output i can see the html tags.< I hope someone can tell me how to do this. Thanks Roggey
-
Hello I'm using System.Windows.Forms.Label and I want to add some text, where one or more words are bold or italic. I tried it with html tags but does not work. Somewhere i did read it should be done by html tags. I did it like this: label1.Text="my <b>test</b> string"; In the output i can see the html tags.< I hope someone can tell me how to do this. Thanks Roggey
Not supported by the label control. You'll either have to use multiple label controls for each word that is different (a messy solution), or come up with your own variant that supports it. The RichTextBox does support different fonts in the text stream, but is a rather heavyweight control to use as a label. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Hello I'm using System.Windows.Forms.Label and I want to add some text, where one or more words are bold or italic. I tried it with html tags but does not work. Somewhere i did read it should be done by html tags. I did it like this: label1.Text="my <b>test</b> string"; In the output i can see the html tags.< I hope someone can tell me how to do this. Thanks Roggey
You can do just what you want in your paint method but you'll need to get a little more involved that you might want to. Basically what you need to do is paint the text of your control yourself. You'll notice that DrawString has a parameter for the font. Just use that and draw the string in sections, one for each font you are using. This also means that you'll need to use MeasureString for each piece as you draw it so you can get the next section to align to the proper place following the preceeding piece. Hope that makes sense.