<p>Is it possible to format certain text in a WinForm Label instead of breaking the text into multiple labels?  Please disregard the HTML tags within the label's text; it's only used to get my point out.</p>

<p>For example:</p>

<pre><code>Dim myLabel As New Label
myLabel.Text = "This is &lt;b&gt;bold&lt;/b&gt; text.  This is &lt;i&gt;italicized&lt;/i&gt; text."
</code></pre>

<p>Which would produce the text in the label as:</p>

<blockquote>
  <p>This is <strong>bold</strong> text.  This is
  <em>italicized</em> text.</p>
</blockquote>

[{'answer_id': 11320, 'author': 'Martin', 'author_id': 770, 'author_profile': 'https://Stackoverflow.com/users/770', 'pm_score': 1, 'selected': False, 'text': "<p>I Would also be interested in finding out if it is possible.</p>\n\n<p>When we couldn't find a solution we resorted to Component Ones 'SuperLabel' control which allows HTML markup in a label.</p>\n"}, {'answer_id': 11323, 'author': 'TheSmurf', 'author_id': 1975282, 'author_profile': 'https://Stackoverflow.com/users/1975282', 'pm_score': 5, 'selected': True, 'text': "<p>That's not possible with a WinForms label as it is. The label has to have exactly one font, with exactly one size and one face. You have a couple of options:</p>\n\n<ol>\n<li>Use separate labels</li>\n<li>Create a new Control-derived class that does its own drawing via GDI+ and use that instead of Label; this is probably your best option, as it gives you complete control over how to instruct the control to format its text</li>\n<li>Use a third-party label control that will let you insert HTML snippets (there are a bunch - check CodeProject); this would be someone else's implementation of #2.</li>\n</ol>\n"}, {'answer_id': 11342, 'author': 'ageektrapped', 'author_id': 631, 'author_profile': 'https://Stackoverflow.com/users/631', 'pm_score': 4, 'selected': False, 'text': '<p>Not really, but you could fake it with a read-only RichTextBox without borders. RichTextBox supports Rich Text Format (rtf).</p>\n'}, {'answer_id': 1602169, 'author': 'Phil', 'author_id': 193962, 'author_profile': 'https://Stackoverflow.com/users/193962', 'pm_score': 3, 'selected': False, 'text': '<ol>\n<li>Create the text as a RTF file in wordpad</li>\n<li>Create Rich text control with no borders and editable = false</li>\n<li>Add the RTF file to the project as a resource</li>\n<li><p>In the Form1_load do</p>\n\n<p>myRtfControl.Rtf = Resource1.MyRtfControlText</p></li>\n</ol>\n'}, {'answer_id': 8677531, 'author': 'Uwe Keim', 'author_id': 107625, 'author_profile': 'https://Stackoverflow.com/users/107625', 'pm_score': 2, 'selected': False, 'text': '<p>There is an excellent article from 2009 on Code Project named "<a href="http://www.codeproject.com/KB/GDI-plus/HtmlRenderer.aspx" rel="nofollow">A Professional HTML Renderer You Will Use</a>" which implements something similar to what the original poster wants.</p>\n\n<p>I use it successfully within several projects of us.</p>\n'}, {'answer_id': 22073163, 'author': 'pKami', 'author_id': 2588964, 'author_profile': 'https://Stackoverflow.com/users/2588964', 'pm_score': 1, 'selected': False, 'text': '<p>Realising this is an old question, my answer is more for those, like me, who still may be looking for such solutions and stumble upon this question.</p>\n\n<p>Apart from what was already mentioned, DevExpress\'s <a href="https://documentation.devexpress.com/#windowsforms/clsDevExpressXtraEditorsLabelControltopic" rel="nofollow">LabelControl</a> is a label that supports this behaviour - <a href="https://documentation.devexpress.com/#windowsforms/CustomDocument9536" rel="nofollow">demo here</a>. Alas, it is part of a paid library.</p>\n\n<p>If you\'re looking for free solutions, I believe <a href="http://htmlrenderer.codeplex.com/" rel="nofollow">HTML Renderer</a> is the next best thing.</p>\n'}, {'answer_id': 23114093, 'author': 'user3541933', 'author_id': 3541933, 'author_profile': 'https://Stackoverflow.com/users/3541933', 'pm_score': 2, 'selected': False, 'text': "<p>Very simple solution:</p>\n\n<ol>\n<li>Add 2 labels on the form, LabelA and LabelB</li>\n<li>Go to properties for LabelA and dock it to left.</li>\n<li>Go to properties for LabelB and dock it to left as well. </li>\n<li>Set Font to bold for LabelA . </li>\n</ol>\n\n<p>Now the LabelB will shift depending on length of text of LabelA.</p>\n\n<p>That's all.</p>\n"}, {'answer_id': 24207716, 'author': 'Geoff', 'author_id': 55487, 'author_profile': 'https://Stackoverflow.com/users/55487', 'pm_score': 4, 'selected': False, 'text': '<p>Another workaround, late to the party: if you don\'t want to use a third party control, and you\'re just looking to call attention to some of the text in your label, <em>and</em> you\'re ok with underlines, you can use a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.linklabel(v=vs.110).aspx" rel="noreferrer">LinkLabel</a>.  </p>\n\n<p>Note that many consider this a \'<a href="https://ux.stackexchange.com/a/18088">usability crime</a>\', but if you\'re not designing something for end user consumption then it may be something you\'re prepared to have on your conscience.</p>\n\n<p>The trick is to add disabled links to the parts of your text that you want underlined, and then globally set the link colors to match the rest of the label.  You can set almost all the necessary properties at design-time apart from the <code>Links.Add()</code> piece, but here they are in code:</p>\n\n<pre><code>linkLabel1.Text = "You are accessing a government system, and all activity " +\n                  "will be logged.  If you do not wish to continue, log out now.";\nlinkLabel1.AutoSize = false;\nlinkLabel1.Size = new Size(365, 50);\nlinkLabel1.TextAlign = ContentAlignment.MiddleCenter;\nlinkLabel1.Links.Clear();\nlinkLabel1.Links.Add(20, 17).Enabled = false;   // "government system"\nlinkLabel1.Links.Add(105, 11).Enabled = false;  // "log out now"\nlinkLabel1.LinkColor = linkLabel1.ForeColor;\nlinkLabel1.DisabledLinkColor = linkLabel1.ForeColor;\n</code></pre>\n\n<p>Result:</p>\n\n<p><img src="https://i.stack.imgur.com/7gLgn.png" alt="enter image description here"></p>\n'}, {'answer_id': 25527349, 'author': 'jakebic', 'author_id': 3293976, 'author_profile': 'https://Stackoverflow.com/users/3293976', 'pm_score': 1, 'selected': False, 'text': "<p>A FlowLayoutPanel works well for your problem. If you add labels to the flow panel and format each label's font and margin properties, then you can have different font styles. Pretty quick and easy solution to get working.</p>\n"}, {'answer_id': 28728824, 'author': 'Nigrimmist', 'author_id': 1151741, 'author_profile': 'https://Stackoverflow.com/users/1151741', 'pm_score': 4, 'selected': False, 'text': '<p>Worked solution for me - using custom RichEditBox. With right properties it will be looked as simple label with bold support.</p>\n<p><strong>1)</strong> First, add your custom RichTextLabel class with disabled caret :</p>\n<pre><code>public class RichTextLabel : RichTextBox\n{\n    public RichTextLabel()\n    {\n        base.ReadOnly = true;\n        base.BorderStyle = BorderStyle.None;\n        base.TabStop = false;\n        base.SetStyle(ControlStyles.Selectable, false);\n        base.SetStyle(ControlStyles.UserMouse, true);\n        base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);\n\n        base.MouseEnter += delegate(object sender, EventArgs e)\n        {\n            this.Cursor = Cursors.Default;\n        };\n    }\n\n    protected override void WndProc(ref Message m)\n    {\n        if (m.Msg == 0x204) return; // WM_RBUTTONDOWN\n        if (m.Msg == 0x205) return; // WM_RBUTTONUP\n        base.WndProc(ref m);\n    }\n}\n</code></pre>\n<p><strong>2)</strong> Split you sentence to words with IsSelected flag, that determine if that word should be bold or no :</p>\n<pre><code>        private void AutocompleteItemControl_Load(object sender, EventArgs e)\n    {\n        RichTextLabel rtl = new RichTextLabel();\n        rtl.Font = new Font(&quot;MS Reference Sans Serif&quot;, 15.57F);\n        StringBuilder sb = new StringBuilder();\n        sb.Append(@&quot;{\\rtf1\\ansi &quot;);\n        foreach (var wordPart in wordParts)\n        {\n            if (wordPart.IsSelected)\n            {\n                sb.Append(@&quot;\\b &quot;);\n            }\n            sb.Append(ConvertString2RTF(wordPart.WordPart));\n            if (wordPart.IsSelected)\n            {\n                sb.Append(@&quot;\\b0 &quot;);\n            }\n        }\n        sb.Append(@&quot;}&quot;);\n\n        rtl.Rtf = sb.ToString();\n        rtl.Width = this.Width;\n        this.Controls.Add(rtl);\n    }\n</code></pre>\n<p><strong>3)</strong> Add function for convert you text to valid rtf (with unicode support!) :</p>\n<pre><code>   private string ConvertString2RTF(string input)\n    {\n        //first take care of special RTF chars\n        StringBuilder backslashed = new StringBuilder(input);\n        backslashed.Replace(@&quot;\\&quot;, @&quot;\\\\&quot;);\n        backslashed.Replace(@&quot;{&quot;, @&quot;\\{&quot;);\n        backslashed.Replace(@&quot;}&quot;, @&quot;\\}&quot;);\n\n        //then convert the string char by char\n        StringBuilder sb = new StringBuilder();\n        foreach (char character in backslashed.ToString())\n        {\n            if (character &lt;= 0x7f)\n                sb.Append(character);\n            else\n                sb.Append(&quot;\\\\u&quot; + Convert.ToUInt32(character) + &quot;?&quot;);\n        }\n        return sb.ToString();\n    }\n</code></pre>\n<p><img src="https://i.stack.imgur.com/4rwhv.png" alt="Sample" /></p>\n<p>Works like a charm for me!\nSolutions compiled from :</p>\n<p><a href="https://stackoverflow.com/questions/4795709/how-to-convert-a-string-to-rtf-in-c">How to convert a string to RTF in C#?</a></p>\n<p><a href="https://stackoverflow.com/questions/4077582/format-text-in-rich-text-box">Format text in Rich Text Box</a></p>\n<p><a href="https://stackoverflow.com/questions/582312/how-to-hide-the-caret-in-a-richtextbox">How to hide the caret in a RichTextBox?</a></p>\n'}, {'answer_id': 29395208, 'author': 'Marinpietri', 'author_id': 3124522, 'author_profile': 'https://Stackoverflow.com/users/3124522', 'pm_score': 0, 'selected': False, 'text': '<p>Yeah.\nYou can implements, using  HTML Render.\nFor you see, click on the link: <a href="https://htmlrenderer.codeplex.com/" rel="nofollow">https://htmlrenderer.codeplex.com/</a>\nI hope this is useful.</p>\n'}, {'answer_id': 33211471, 'author': 'Martin Braun', 'author_id': 1540350, 'author_profile': 'https://Stackoverflow.com/users/1540350', 'pm_score': 2, 'selected': False, 'text': '<h1>AutoRichLabel</h1>\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://i.stack.imgur.com/cETHe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cETHe.png" alt="AutoRichLabel with formatted RTF content"></a></p>\n\n<p>I was solving this problem by building an <code>UserControl</code> that contains a <code>TransparentRichTextBox</code> that is readonly. The <code>TransparentRichTextBox</code> is a <code>RichTextBox</code> that allows to be transparent:</p>\n\n<p>TransparentRichTextBox.cs: </p>\n\n<pre><code>public class TransparentRichTextBox : RichTextBox\n{\n    [DllImport("kernel32.dll", CharSet = CharSet.Auto)]\n    static extern IntPtr LoadLibrary(string lpFileName);\n\n    protected override CreateParams CreateParams\n    {\n        get\n        {\n            CreateParams prams = base.CreateParams;\n            if (TransparentRichTextBox.LoadLibrary("msftedit.dll") != IntPtr.Zero)\n            {\n                prams.ExStyle |= 0x020; // transparent \n                prams.ClassName = "RICHEDIT50W";\n            }\n            return prams;\n        }\n    }\n}\n</code></pre>\n\n<p>The final <code>UserControl</code> acts as wrapper of the <code>TransparentRichTextBox</code>. Unfortunately, I had to limit it to <code>AutoSize</code> on my own way, because the <code>AutoSize</code> of the <code>RichTextBox</code> became broken.</p>\n\n<p>AutoRichLabel.designer.cs: </p>\n\n<pre><code>partial class AutoRichLabel\n{\n    /// &lt;summary&gt; \n    /// Required designer variable.\n    /// &lt;/summary&gt;\n    private System.ComponentModel.IContainer components = null;\n\n    /// &lt;summary&gt; \n    /// Clean up any resources being used.\n    /// &lt;/summary&gt;\n    /// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;\n    protected override void Dispose(bool disposing)\n    {\n        if (disposing &amp;&amp; (components != null))\n        {\n            components.Dispose();\n        }\n        base.Dispose(disposing);\n    }\n\n    #region Component Designer generated code\n\n    /// &lt;summary&gt; \n    /// Required method for Designer support - do not modify \n    /// the contents of this method with the code editor.\n    /// &lt;/summary&gt;\n    private void InitializeComponent()\n    {\n        this.rtb = new TransparentRichTextBox();\n        this.SuspendLayout();\n        // \n        // rtb\n        // \n        this.rtb.BorderStyle = System.Windows.Forms.BorderStyle.None;\n        this.rtb.Dock = System.Windows.Forms.DockStyle.Fill;\n        this.rtb.Location = new System.Drawing.Point(0, 0);\n        this.rtb.Margin = new System.Windows.Forms.Padding(0);\n        this.rtb.Name = "rtb";\n        this.rtb.ReadOnly = true;\n        this.rtb.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;\n        this.rtb.Size = new System.Drawing.Size(46, 30);\n        this.rtb.TabIndex = 0;\n        this.rtb.Text = "";\n        this.rtb.WordWrap = false;\n        this.rtb.ContentsResized += new System.Windows.Forms.ContentsResizedEventHandler(this.rtb_ContentsResized);\n        // \n        // AutoRichLabel\n        // \n        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\n        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n        this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;\n        this.BackColor = System.Drawing.Color.Transparent;\n        this.Controls.Add(this.rtb);\n        this.Name = "AutoRichLabel";\n        this.Size = new System.Drawing.Size(46, 30);\n        this.ResumeLayout(false);\n\n    }\n\n    #endregion\n\n    private TransparentRichTextBox rtb;\n}\n</code></pre>\n\n<p>AutoRichLabel.cs: </p>\n\n<pre><code>/// &lt;summary&gt;\n/// &lt;para&gt;An auto sized label with the ability to display text with formattings by using the Rich Text Format.&lt;/para&gt;\n/// &lt;para&gt;\xad&lt;/para&gt;\n/// &lt;para&gt;Short RTF syntax examples: &lt;/para&gt;\n/// &lt;para&gt;\xad&lt;/para&gt;\n/// &lt;para&gt;Paragraph: &lt;/para&gt;\n/// &lt;para&gt;{\\pard This is a paragraph!\\par}&lt;/para&gt;\n/// &lt;para&gt;\xad&lt;/para&gt;\n/// &lt;para&gt;Bold / Italic / Underline: &lt;/para&gt;\n/// &lt;para&gt;\\b bold text\\b0&lt;/para&gt;\n/// &lt;para&gt;\\i italic text\\i0&lt;/para&gt;\n/// &lt;para&gt;\\ul underline text\\ul0&lt;/para&gt;\n/// &lt;para&gt;\xad&lt;/para&gt;\n/// &lt;para&gt;Alternate color using color table: &lt;/para&gt;\n/// &lt;para&gt;{\\colortbl ;\\red0\\green77\\blue187;}{\\pard The word \\cf1 fish\\cf0  is blue.\\par&lt;/para&gt;\n/// &lt;para&gt;\xad&lt;/para&gt;\n/// &lt;para&gt;Additional information: &lt;/para&gt;\n/// &lt;para&gt;Always wrap every text in a paragraph. &lt;/para&gt;\n/// &lt;para&gt;Different tags can be stacked (i.e. \\pard\\b\\i Bold and Italic\\i0\\b0\\par)&lt;/para&gt;\n/// &lt;para&gt;The space behind a tag is ignored. So if you need a space behind it, insert two spaces (i.e. \\pard The word \\bBOLD\\0  is bold.\\par)&lt;/para&gt;\n/// &lt;para&gt;Full specification: http://www.biblioscape.com/rtf15_spec.htm &lt;/para&gt;\n/// &lt;/summary&gt;\npublic partial class AutoRichLabel : UserControl\n{\n    /// &lt;summary&gt;\n    /// The rich text content. \n    /// &lt;para&gt;\xad&lt;/para&gt;\n    /// &lt;para&gt;Short RTF syntax examples: &lt;/para&gt;\n    /// &lt;para&gt;\xad&lt;/para&gt;\n    /// &lt;para&gt;Paragraph: &lt;/para&gt;\n    /// &lt;para&gt;{\\pard This is a paragraph!\\par}&lt;/para&gt;\n    /// &lt;para&gt;\xad&lt;/para&gt;\n    /// &lt;para&gt;Bold / Italic / Underline: &lt;/para&gt;\n    /// &lt;para&gt;\\b bold text\\b0&lt;/para&gt;\n    /// &lt;para&gt;\\i italic text\\i0&lt;/para&gt;\n    /// &lt;para&gt;\\ul underline text\\ul0&lt;/para&gt;\n    /// &lt;para&gt;\xad&lt;/para&gt;\n    /// &lt;para&gt;Alternate color using color table: &lt;/para&gt;\n    /// &lt;para&gt;{\\colortbl ;\\red0\\green77\\blue187;}{\\pard The word \\cf1 fish\\cf0  is blue.\\par&lt;/para&gt;\n    /// &lt;para&gt;\xad&lt;/para&gt;\n    /// &lt;para&gt;Additional information: &lt;/para&gt;\n    /// &lt;para&gt;Always wrap every text in a paragraph. &lt;/para&gt;\n    /// &lt;para&gt;Different tags can be stacked (i.e. \\pard\\b\\i Bold and Italic\\i0\\b0\\par)&lt;/para&gt;\n    /// &lt;para&gt;The space behind a tag is ignored. So if you need a space behind it, insert two spaces (i.e. \\pard The word \\bBOLD\\0  is bold.\\par)&lt;/para&gt;\n    /// &lt;para&gt;Full specification: http://www.biblioscape.com/rtf15_spec.htm &lt;/para&gt;\n    /// &lt;/summary&gt;\n    [Browsable(true)]\n    public string RtfContent\n    {\n        get\n        {\n            return this.rtb.Rtf;\n        }\n        set\n        {\n            this.rtb.WordWrap = false; // to prevent any display bugs, word wrap must be off while changing the rich text content. \n            this.rtb.Rtf = value.StartsWith(@"{\\rtf1") ? value : @"{\\rtf1" + value + "}"; // Setting the rich text content will trigger the ContentsResized event. \n            this.Fit(); // Override width and height. \n            this.rtb.WordWrap = this.WordWrap; // Set the word wrap back. \n        }\n    }\n\n    /// &lt;summary&gt;\n    /// Dynamic width of the control. \n    /// &lt;/summary&gt;\n    [Browsable(false)]\n    public new int Width\n    {\n        get\n        {\n            return base.Width;\n        } \n    }\n\n    /// &lt;summary&gt;\n    /// Dynamic height of the control. \n    /// &lt;/summary&gt;\n    [Browsable(false)]\n    public new int Height\n    {\n        get\n        {\n            return base.Height;\n        }\n    }\n\n    /// &lt;summary&gt;\n    /// The measured width based on the content. \n    /// &lt;/summary&gt;\n    public int DesiredWidth { get; private set; }\n\n    /// &lt;summary&gt;\n    /// The measured height based on the content. \n    /// &lt;/summary&gt;\n    public int DesiredHeight { get; private set; }\n\n    /// &lt;summary&gt;\n    /// Determines the text will be word wrapped. This is true, when the maximum size has been set. \n    /// &lt;/summary&gt;\n    public bool WordWrap { get; private set; }\n\n    /// &lt;summary&gt;\n    /// Constructor. \n    /// &lt;/summary&gt;\n    public AutoRichLabel()\n    {\n        InitializeComponent();\n    }\n\n    /// &lt;summary&gt;\n    /// Overrides the width and height with the measured width and height\n    /// &lt;/summary&gt;\n    public void Fit()\n    {\n        base.Width = this.DesiredWidth;\n        base.Height = this.DesiredHeight;\n    }\n\n    /// &lt;summary&gt;\n    /// Will be called when the rich text content of the control changes. \n    /// &lt;/summary&gt;\n    private void rtb_ContentsResized(object sender, ContentsResizedEventArgs e)\n    {\n        this.AutoSize = false; // Disable auto size, else it will break everything\n        this.WordWrap = this.MaximumSize.Width &gt; 0; // Enable word wrap when the maximum width has been set. \n        this.DesiredWidth = this.rtb.WordWrap ? this.MaximumSize.Width : e.NewRectangle.Width; // Measure width. \n        this.DesiredHeight = this.MaximumSize.Height &gt; 0 &amp;&amp; this.MaximumSize.Height &lt; e.NewRectangle.Height ? this.MaximumSize.Height : e.NewRectangle.Height; // Measure height. \n        this.Fit(); // Override width and height. \n    }\n}\n</code></pre>\n\n<p>The syntax of the rich text format is quite simple: </p>\n\n<p>Paragraph: </p>\n\n<pre><code>{\\pard This is a paragraph!\\par}\n</code></pre>\n\n<p>Bold / Italic / Underline text: </p>\n\n<pre><code>\\b bold text\\b0\n\\i italic text\\i0\n\\ul underline text\\ul0\n</code></pre>\n\n<p>Alternate color using color table: </p>\n\n<pre><code>{\\colortbl ;\\red0\\green77\\blue187;}\n{\\pard The word \\cf1 fish\\cf0  is blue.\\par\n</code></pre>\n\n<p>But please note: Always wrap every text in a paragraph. Also, different tags can be stacked (i.e. <code>\\pard\\b\\i Bold and Italic\\i0\\b0\\par</code>) and the space character behind a tag is ignored. So if you need a space behind it, insert two spaces (i.e. <code>\\pard The word \\bBOLD\\0  is bold.\\par</code>). To escape <code>\\</code> or <code>{</code> or <code>}</code>, please use a leading <code>\\</code>. \nFor more information there is a <a href="http://www.biblioscape.com/rtf15_spec.htm" rel="nofollow noreferrer">full specification of the rich text format online</a>. </p>\n\n<p>Using this quite simple syntax you can produce something like you can see in the first image. The rich text content that was attached to the <code>RtfContent</code> property of my <code>AutoRichLabel</code> in the first image was: </p>\n\n<pre><code>{\\colortbl ;\\red0\\green77\\blue187;}\n{\\pard\\b BOLD\\b0  \\i ITALIC\\i0  \\ul UNDERLINE\\ul0 \\\\\\{\\}\\par}\n{\\pard\\cf1\\b BOLD\\b0  \\i ITALIC\\i0  \\ul UNDERLINE\\ul0\\cf0 \\\\\\{\\}\\par}\n</code></pre>\n\n<blockquote>\n  <p><a href="https://i.stack.imgur.com/cETHe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cETHe.png" alt="AutoRichLabel with formatted RTF content"></a></p>\n</blockquote>\n\n<p>If you want to enable word wrap, please set the maximum width to a desired size. However, this will fix the width to the maximum width, even when the text is shorter. </p>\n\n<p>Have fun! </p>\n'}]
['https://Stackoverflow.com/questions/11311', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/299/']