超链接到c#中的一行richtextbox [英] Hyperlink to a line of richtextbox in c#
本文介绍了超链接到c#中的一行richtextbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种在RichTextBox中创建指向同一RichTextBox文本行的HyperLink的方法。
我刚刚发现如何做到这一点使用Internet链接但我找不到使用控件内部相同文本的方法(如MS Word中指向标题或书签的超链接)。
先谢谢。 - CCB
我尝试过的事情:
'直到现在我刚刚发现如何使用互联网链接创建超链接,而不是使用精确的文本行。
I am looking a way to create a HyperLink in a RichTextBox pointing to a line of the text of the same RichTextBox.
I just found how to do that with Internet Links but I don't find a way to do it with the same text inside of the control (like Hyperlinks in MS Word pointing to a header or bookmark).
Thanks in Advance. - CCB
What I have tried:
'Til now I just found how to make hyperlink with internet links not with exact lines of text.
推荐答案
没有任何内置支持这一点。您将创建自己的HyperLink版本,其中包含用于标识您要去的地方的数据,一个标记,而不是行号。
RichTextBox中的行号不是您在屏幕上看到的可见行。例如,如果您在一行中有一行CR,那么此行可以使用屏幕上任意数量的行在屏幕上呈现,但无论屏幕上有多少行,都只有一行文本在RichTextBox中。
这里有几篇关于CP的文章描述了你的内容。两者都有相同的标题,但它们是不同的文章:
与RichTextBox中的任意文本链接 [ ^ ]
与RichTextBox中的任意文本链接 [ ^ ]
There is nothing built in that supports this. You'd be creating your own version of a HyperLink complete with the data to identify the place you wanted to go to, a tag of sorts, not a line number.
Line numbers in a RichTextBox are not the visible lines you see on screen. For example, if you have a single line of text with a CR at the end this line can be rendered on screen using any number of lines on screen, though no matter how many lines are on the screen, there is only 1 line of text in the RichTextBox.
There's a couple of articles here on CP that describe something along the lines of what you are. Both have the same title but they are different articles:
Links with Arbitrary Text in a RichTextBox[^]
Links with arbitrary text in a RichTextBox[^]
这篇关于超链接到c#中的一行richtextbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文