c# RichTextBox "real" urls?

Posted on 2005-04-08
Last Modified: 2010-05-18
ok I am not new to c#  but there must be an answer to this one... I am stumped!

The story so far ... I wanted to do have email functionality in my program, so after looking around I finally went for a VERY basic RichTextBox with an attached hand made rtf->(BASIC) html converter that sends the simple edits as HTML for my customers to write emails ... I want to write html very basically and for my needs my RichTextBox works fine ... with one problem

The only feature I am missing is Hyperlinks. And its MISSION CRITICAL. The nearest I can get is to do a "DetectUrl" work alike, where I physically screen the rtf for a string beginning "http://blah" and then I enclose that in a link in my HTML. It is a bad halfway house though. The PROBLEM is that I can't see an easy way of "combining" the Url behind some "link text"

a) what I want to make : <a href="">my link</a>
b) what I can do easily (from rtf text "") : <a href=""></a>

I am stuck, I fear I have to disbale DetectUrls, go DEEP into rtf and somehow add comments (possibly) that can't bee seen in the box the user sees in but are pseudo written as "underlined in blue" and then I am terrified of mucking about that much. the user if he ever editted round such text would maybe make a RIGHT mess.. Is there anyone who has done this before? Is there an "easy" way of doing this? Should I be using RichTextBox's at all? I want html really, I only used rtf becaus eits there and its free.

Am I making any sense?

Question by:conan1975
    LVL 5

    Accepted Solution

    probably you may use something like this....

    this is an extension of the can insert links with arbitrary text and then handle the LinkClicked event.

    Author Comment

    OK... You know, I was waiting to post my eventual solution... I had to make significant modifications after following RoninThe's suggestion in order to parse fully fleged RTF into HTML (with links!) I finally did it though (buts its in too many places in my code to parcel easily!)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now