Solved

Windows Forms show <a> tags as links

Posted on 2016-07-22
5
35 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]
Comment Utility
you will need to use the web browser control instead of the rich text control
0
 
LVL 20

Author Comment

by:Russ Suter
Comment Utility
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]
Comment Utility
sorry: not possible.
0
 
LVL 20

Author Comment

by:Russ Suter
Comment Utility
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
Comment Utility
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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

8 Experts available now in Live!

Get 1:1 Help Now