.NET 4.5中似乎不存在RichTextBox.InsertLink。 [英] RichTextBox.InsertLink doesn't seem to exist in .NET 4.5.

查看:77
本文介绍了.NET 4.5中似乎不存在RichTextBox.InsertLink。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个可点击的链接到不包含www的RichTextBox。等等,但是那里的所有解决方案都不再有效。

我正在使用带有.NET4.5的VS2013

RichTextBox.InsertLink似乎不再存在。

RichTextBox.IsDocumentEnabled似乎不再存在。

Hyperlink和TextPointer似乎不再存在。



显然这是如何处理的根本改变,但我无法在任何地方找到任何文件。

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.

推荐答案

会员11201346写道:
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."

在Windows窗体中,没有:



RichTextBox。 InsertLink

RichTextBox.IsDocumentEnabled

Hyperlink and TextPointer



这些是属性/方法/等。 WPF RichTextBox。



WinForms RichTextBox有一个'DetectUrls属性,如果设置为'true,将识别url:但是,正如您所知,链接必须从以下一个开始::http:,file:,mailto:,ftp:,https:,gopher:,nntp:,prospero:,telnet:,news:,wais:,outlook:...必须是一个完整格式正确的链接。



输入行为作为链接的任意文本(当你点击它时,触发一个EventHandler为RTB LinkClicked事件:你必须使用Windows API,并将'DetectUrls'设置为'false。



幸运的是,CodeProject是你的朋友,以下是这样做的:与RichTextBox中任意文本的链接:[ ^ ]。



而且,你更幸运,因为:这里的新文章(2014年10月)似乎超越了第一篇文章提供的内容: AnyLinkRichTextBox:[ ^ ]。



我尝试了'AnyRichTextBox,你会看到我对这篇文章做出的一些评论,以及作者的回应。我不确定作者是否修复了我报告的错误。

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.


这篇关于.NET 4.5中似乎不存在RichTextBox.InsertLink。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆