Click here to Skip to main content
15,668,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to add a clickable link to a RichTextBox that does not include "www." etc, but all the solutions out there no longer work.
I am using VS2013 with .NET4.5
RichTextBox.InsertLink no longer seems to exist.
RichTextBox.IsDocumentEnabled no longer seems to exist.
Hyperlink and TextPointer don't seem to exist any longer.

Obviously there has been a fundamental change in how this is all handled, but I can't find documentation for any of it anywhere.
Posted
Updated 27-Oct-21 0:23am
v2
Comments
BillWoodruff 3-Nov-14 2:04am    
This is WPF: please add that Tag to your post. To help you I think we need to see your code and-or xaml.
Member 11201346 3-Nov-14 2:21am    
Thanks Bill, but no, this is in Windows.Forms. I don't have code because what is supposed to work (listed above) does not even compile. They've deleted the above methods and properties from RichTextBox. MS changed how all this works without explaining what the changes are.
Afzaal Ahmad Zeeshan 3-Nov-14 2:27am    
If so, why not add the .dll library that has those functions and properties? I have in case check the Windows.Forms API and Windows.Controls (WPF) API, and there isn't this method present in both of the cases.

1 solution

Member 11201346 wrote:
"Thanks Bill, but no, this is in Windows.Forms. I don't have code because what is supposed to work (listed above) does not even compile. They've deleted the above methods and properties from RichTextBox. MS changed how all this works without explaining what the changes are."
In Windows Forms, there is no:

"RichTextBox.InsertLink
RichTextBox.IsDocumentEnabled
Hyperlink and TextPointer"

Those are properties/methods/etc. of the WPF RichTextBox.

The WinForms RichTextBox has a 'DetectUrls property which, if set to 'true, will recognize url's: but, as you may know, the links must start with one-of: ":http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:, outlook:" ... has to be a full properly formatted link.

To enter arbitrary Text that behaves as a link (when you click it, triggers an EventHandler for the RTB LinkClicked Event: you have to use the Windows API, and set 'DetectUrls to 'false.

Fortunately, CodeProject is your friend, and here's how that's done: "Links with arbitrary text in a RichTextBox:" [^].

And, you are even luckier, because: a newer article here (October, 2014) appears to go beyond what the first article offers: "AnyLinkRichTextBox:" [^].

I have tried the 'AnyRichTextBox, and you'll see some comments I made on the article, and the author's response. I'm not sure if the author has fixed the bug I reported.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900