rtftextbox 和文档内的超链接/锚点
几个小时前,我发现使用标准 .net 2.0 winforms 控件(RichTextBox)显示 *.rtf 文档非常容易。 它甚至可以显示图片,这真的很酷,但对我来说,缺少一个功能 - 超链接。 我准备了 *.rtf 文档,其中包含一些指向文档内段落的超链接。 然后我将此文件放入资源中并加载到控件的 rtf 属性中,但不幸的是,单击链接不起作用。 是否有可能的黑客或解决方法来启用超链接?
编辑:
我的客户将准备一份简短的文档(假设一份 *.docx 文件或一份 *.html 文件)。
它将包含几个章节,我们希望将小目录放在文档的顶部。
预期的行为是用户单击主题,控件将其内容滚动到文档中的所需位置。
所以也许这不是关于链接而是关于书签。
好的,我将尝试描述所需解决方案的大部分。
我的客户将准备一份简短的文档(假设一份 *.docx 文件或一份 *.html 文件)。
它将包含几个章节,我们希望将小目录放在文档的顶部。
预期的行为是用户单击主题,控件将其内容滚动到文档中的所需位置。
所以也许这不是关于链接而是关于书签。
A few hours ago I found that it's really easy to display *.rtf document using standart .net 2.0 winforms control (RichTextBox). It's really cool that it can display even pictures, but for me there's one missing feature - hyperlinking.
I prepared *.rtf document with a few hyperlinks to paragraphs inside document. Then I put this file into resources and loaded to rtf property of control but unluckly, clicking on links doesn't work.
Is there possible a hack or workaround to enable hyperlinks?
EDIT:
My customer will prepare one short document (let's say one *.docx file or one *.html file).
It will contain a few chapters and we want to place small table of contents at the top of document.
The expected behaviour is that user click topic and the control scroll its content to desired place in document.
So maybe it's not about links but about bookmarking.
OK, I'll try to describe larger part of needed solution.
My customer will prepare one short document (let's say one *.docx file or one *.html file).
It will contain a few chapters and we want to place small table of contents at the top of document.
The expected behaviour is that user click topic and the control scroll its content to desired place in document.
So maybe it's not about links but about bookmarking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的链接格式如何?DetectUrl 是否正确?
来自代码项目 -> 仅以一种已识别协议(http:、file:、mailto:、ftp:、https:、gopher:、nntp:、prospero:、telnet:、news:、wais:、outlook:)开头的链接会被识别并重新格式化。
http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
http:// msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.detecturls(VS.80).aspx
Microsoft 文章提供了有关 LinkClicked 事件的示例。
How are your links formatted and is DetectUrl true?
From codeproject -> only links starting with one of the recognized protocols (http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:, outlook:) are recognized and reformatted.
http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.detecturls(VS.80).aspx
The microsoft article has an example on the LinkClicked event.