RichTextBox and Detecting URL's

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I've got an interesting, all the documentation for the DetectUrls property states that the richtextbox will automatically make URL's as hyperlinks when the DetectUrls property is set to true.

With that in mind, I think I'm missing something. I have a RTB that has it's text property set from a StringBuilder after all the pieces are collected from various places.

Some of the data does have email addresses and I thought by simply having the email addresses as part of the text the RTB would automatically highlight and underline the addresses, and I have included code in the LinkClicked event for launching a web browser to email the address shown.

However this is not the case, the email addresses are shown in plain black text with no hyperlink association.

Did I miss something?
 
Ok, after some further testing the DetectUrls works, it's just that email addresses aren't url's so I'll have to come up with a method of detecting them manually and adding them to the RTB as a url
 
If you prefix with protocol the email is detected as url, for example "mailto:x@domain.com" (or mailto://x@domain.com). It's the same with webpage url if you don't start with "www." then "domain.com" is not detected, "http://domain.com" is.
 
problem is, i can't have it showing as "mailto:x@domain.com", it has to be "x@domain.com" showing in the RTB.

I'll get to working on a solution sometime next week
 
I decided to take a shortcut, instead of using an RTB control I'm using the .Net 2.0 WebBrowser control
 
Back
Top