Solved

Windows Forms show <a> tags as links

Posted on 2016-07-22
5
49 Views
Last Modified: 2016-07-26
In a Windows Forms application, I have a RichTextBox control with the DetectUrls property set to true.

Using the following text:
Hello, and welcome to <a href="http://www.colgate.com">Colgate toothpaste</a>. Or if you prefer, just go to http://www.crest.com.
I get this result:
rtbWhat I really need is for it to render the string as a web browser would so it would look like this:
web
I'd even be OK if it rendered both the <a> tag and the explicit URL both as links but that's not necessary. What I really need is a way to render the <a> tag as a link. Any idea how I can accomplish this?
0
Comment
Question by:Russ Suter
  • 3
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41725119
you will need to use the web browser control instead of the rich text control
0
 
LVL 20

Author Comment

by:Russ Suter
ID: 41725120
I'm aware that the WebBrowser control will do this. Unfortunately that's not an option. I need to figure out how to make a RichTextBox (or similar) control do this.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41725137
sorry: not possible.
0
 
LVL 20

Author Comment

by:Russ Suter
ID: 41725139
Sorry, that's never an acceptable answer. It's always possible, even if I have to subclass the RichTextBox control myself. It seems that's what I'll be doing unless someone else can come up with an alternative.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 41725158
Then it's no longer a pure richtextcontrol, but i presume you will consider that playing with words, which is ok for me.

Technically it puts linklabel objects into the text, so you can do indeed the same.
I would likely disable the detecturl property and put the links for both syntaxes.
As i am far from a pc for another 3 weeks, i cannot work out any code myself, but i understand tgat will not be an issue for you, as you know how to subclass existing control classes.

Note that i have never be a fan of neither the richtext nor the webbrowser control.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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