views:

299

answers:

1

I'm using a RichTextBox to display an RTF file, which includes a single hyperlink. The link text is not a URL (the target is a valid URL). The RTF was created with Word. Both Word and Wordpad properly recognize the links (Wordpad does not launch the links, but shows the appropriate hand cursor).

When I load the RTF into a RichTextBox the links appear formatted correctly (blue and underlined), but rather than behaving like a link, when the cursor moves over the link it remains an I-beam, the LinkClicked event will not fire, and it actually shows the target between angle brackets after the link (this does not seem correct). Since the link text is not a URL, DetectUrls does not help here.

Is there a reason that RichTextBox does not properly handle these links, or a way to make them work as expected?

Edit:

Here is the code.

TipView.Rtf = tips[tipIndex];
// I've also tried TipView.LoadFile, with identical result

To reproduce the issue, create an RTF document with Word (I'm using 2000) containing one link whose text is not a URL but targets a valid URL, and programatically load the .rtf file into a RichTextBox (I'm using DotNet 2.0 in C# Express 2008).

+1  A: 

Try this site several people have the same issue. It uses VB but you should be able to get some ideas.

http://www.daniweb.com/forums/thread202171.html

Menuta
I actually stumbled upon the Code Project article linked to in that discussion. The solution works, but I'm hoping that someone can explain why RichTextBox can't handle RTF links properly, or how to fix it.
Snarfblam