各位:
本人乃新手,遇到了一个问题。我想在一个Richtextbox中显示超链接,但好象richtextbox中只能探测到www.xxx.xxx类型的文本当作正确的超链。而我想象网页中那样显示一些友好的名字人作为超链,如here作为一个超链。
如何实现,请指点一二,谢谢!
本人乃新手,遇到了一个问题。我想在一个Richtextbox中显示超链接,但好象richtextbox中只能探测到www.xxx.xxx类型的文本当作正确的超链。而我想象网页中那样显示一些友好的名字人作为超链,如here作为一个超链。
如何实现,请指点一二,谢谢!
public static void InsertURL(RichTextBox rtb, string name,string url)
{
StringBuilder _rtf = new StringBuilder();
_rtf.Append("<a href='"+url+"'>");
_rtf.Append(name);
_rtf.Append("</a>");
rtb.SelectedRtf = _rtf.ToString();
}
使用:
InsertURL(this.richTxtBox,"here","http://www.csdn.net");
因为那是将str按照文本格式写入rtf文档。那样会自动添加许多其他的标签。
Document Area
Once the RTF header is defined, the RTF reader has enough information to correctly read the actual document text. The document area has the following syntax:
<document> <info>? <docfmt>* <section>+
Information Group
The \info control word introduces the information group, which contains information about the document. This can include the title, author, keywords, comments, and other information specific to the file. This information is for use by a document-management utility, if available.
The information group has the following syntax:
<info> '{' <title>? & <subject>? & <author>? & <manager>? & <company>? <operator>? & <category>? & <keywords>? & <comment>? & \version? & <doccomm>? & \vern? & <creatim>? & <revtim>? & <printim>? & <buptim>? & \edmins? & \nofpages? & \nofwords? \nofchars? & \id? '}'
<title> '{' \title #PCDATA '}'
<subject> '{' \subject #PCDATA '}'
<author> '{' \author #PCDATA '}'
<manager> {' \manager #PCDATA '}'
<company> {' \company #PCDATA '}'
<operator> '{' \operator #PCDATA '}'
<category> {' \category #PCDATA '}'
<keywords> '{' \keywords #PCDATA '}'
<comment> '{' \comment #PCDATA '}'
<doccomm> '{' \doccomm #PCDATA '}'
<hlinkbase> '{' \hlinkbase #PCDATA '}'
<creatim> '{' \creatim <time> '}'
<revtim> '{' \revtim <time> '}'
<printim> '{' \printim <time> '}'
<buptim> '{' \buptim <time> '}'
<time> \yr? \mo? \dy? \hr? \min? \sec?Some applications, such as Word, ask the user to type this information when saving the document in its native format. If the document is then saved as an RTF file or translated into RTF, the RTF writer specifies this information using control words in the following table. These control words are destinations, and both the control words and the text should be enclosed in braces ({ }).
Control word Meaning
\title Title of the document. This is a destination control word.
\subject Subject of the document. This is a destination control word.
\author Author of the document. This is a destination control word.
\manager Manager of the author. This is a destination control word.
\company Company of the author. This is a destination control word.
\operator Person who last made changes to the document. This is a destination control word.
\category Category of the document. This is a destination control word.
\keywords Selected keywords for the document. This is a destination control word.
\comment Comments; text is ignored. This is a destination control word.
\versionN Version number of the document.
\doccomm Comments displayed in the Summary Info or Properties dialog box in Word. This is a destination control word.
\hlinkbase The base address that is used for the path of all relative hyperlinks inserted in the document. This can be a path or an Internet address (URL).