RichTextLabel WinForms Control


A couple of weeks ago, I've had a busy weekend working on a soon-to-be-released .NET component. The feature I was working on was a nag dialog that the evaluation version of the component should display occasionally. Obviously, I wanted the dialog to show up quickly and also to look attractively . I also wanted to be able to display an active hyperlink that would take the user to the product's site when clicked.

Another possible example needing a similar functionality might be an 'About' dialog box. (I've seen a couple of 'About' dialogs containing just plain text, even with non-clickable homepage and 'purchase' hyperlinks). Splash screens could also have been more attractive displaying program information (name, version number...) in distinct fonts and colors, for example. Or, consider the various 'TIP:' labels scattered throughout dialog boxes in some applications. More often than not, decent formatting could have improved readability and thus the usability of the dialog.

Let's go back to my nag dialog. As I said, I wanted to use formatted text and graphics to make it look nice and "cool". I've considered the following possible implementation options:

  1. Several differently formatted Label and LinkLabel controls.

    I've abandoned this option quickly, because the formatted text should appear as "flowing" and I wasn't able to layout the differently formatted labels correctly.
  2. Third-party HTML rendering controls.

    I've found a couple of ActiveX controls, but I didn't want to introduce any additional dependencies (and the interop overhead), so I didn't research the controls further.
  3. Hosting the WebBrowser control.

    This is an ActiveX control, so it suffers from the same drawbacks as the previous approach. It's also too slow for the purposes of my nag dialog.
  4. The RichTextBox control.

    The control supports text formatting and embedded graphics. It has also the DetectUrls property meaning it can underline properly formatted URLs, display the 'hand' cursor when an user hovers the mouse over the link and it can also raise the LinkClicked event when the link is clicked. The event can be handled with a small amount of code to show the URL in the user's browser.

    In addition, by setting a couple of the control's appearance properties, it could be made to look and act like a non-editable, formatted label. And the control's display performance is really good.

For me, RichTextBox was a clear winner.

You might also like...


About the author

Palo Mraz

Palo Mraz United States

I live in Slovakia with my wife, two sons (fulltime), one daughter (occasionally) and a dog. I've been doing Microsoft Windows development since 1988; primarily in VB. I'm a big fan of the MS .N...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray