Solved

Windows Forms show <a> tags as links

Posted on 2016-07-22
5
54 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 143

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 143

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 143

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 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