Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 41,964 times

Contents

Downloads

Related Categories

RichTextLabel WinForms Control - Introduction

palom

Introduction

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.

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 .NET framework, publisher of the www.VBInfoZine.com ezine and the author of the Dynamic AutoComplete Tool .NET component (dact.lamarvin.com).

Comments

  • Re: [4584] RichTextLabel WinForms Control

    Posted by dgauerke on 26 Jul 2006

    I moved the control into a seperate dll (along with the editor), but the editor no longer finds the embedded rtf files in the exe.  When I move the control back into the main application it wo...

  • doubt

    Posted by sherry on 22 Nov 2004

    i have a doubt...
    when we use an input box in vb.net on clicking the ok button i get the input into the text box where required but how to activate the cancel button???